ABAP – SD Document flow monitoring

SAPAll documents created in SAP SD module goes sooner or later through VBFA table where all transitions are stored.The main idea of VBFA table contents is that you are able to track all transitions (documents flow) during the whole logistic chain.

Besides other fields of VBFA the main idea is in it’s KEY fields named:

  • VBELV + POSNV (Preceding SD Document + Item)
  • VBELN + POSNN (Subsequent SD Document + Item)
  • VBTYP_N (Document category of subsequent document)
  • VBTYP_V (Document category of preceding SD document – NOT A KEY FIELD)

If you examine VBTYP_N field and its domain (VBTYP), you’ll find pre-defined types (see attachment VBFA-VBTYP_V -> VBFA-VBTYP_N)

For the following example where Delivery is being Invoiced and such invoice is then canceled, you’ll get 2 entries in VBFA table created:

  1. Delivery (J) -> Invoice (M)
  2. Invoice (M) -> Invoice cancelation (N)

Document flow

Information relevant to documents hidden under VBELV and VBELN key fields can than be found in their corresponding tables:

  1. Material Management
    • MSEG – Segment of Material Document
    • MKPF – Header for Material Document
  2. Finance
    • BSEG – Accounting Document Segment
    • BKPF – Accounting Document Header
    • BSEG/BKPF pulls data relevant to company code
  3. MM / FI
    • RSEG – Document Item: Incoming Invoice
    • RKPF -Document Header: Reservation
    • RBKP – Document Header: Invoice Receipt
    • RSEG/RKPF does not have the field Company code it only takes incoming invoice and reservation irrespective of company code

The same as VFBA for SD is VTFA table for Shipment documents flow.
Similarly there is table EKBE for monitoring history of a Purchasing document and EKBZ – History per Purchasing Document: Delivery Costs.

One of possible links between an Invoice Receipt and a Material Document is a Purchase Order
For Example we have:

  • Pucharse Order EBELN = 1400095975 and one Line item EBELP = 1.
  • Material Document MBLNR = 5001321695 in MSEG
  • Accounting document for invoice BELNR = 5103166127 in BKPF
  • In MSEG for MBLNR = 5001321695 we get
    • EBELN  = 1400095975
    • EBELP = 1
  • In BSEG for BELNR =  5103166127 for the entry belonging to GR/IR account (HKONT), we get
    • EBELN  = 1400095975
    • EBELP = 1

One of possible links between MKPF and BKPF is

  • Concatente MKPF-MBLNR, MKPF-MJAHR into a temporary variable
  • Select from BKPF with AWTYP = ‘MKPF’ and AWKEY = <Concatenated_string>



Leave a Reply