Sub topic 2
What Document Flow Is and Why It Exists
This chapter assumes you can navigate the SAP GUI, know what SD, MM and FI cover, and understand that business documents have a header and items. It builds the working model that the later chapters use.
The problem document flow solves
A single sale touches several documents. A sales order is followed by a delivery, a goods issue (a material document), a billing document and an accounting document. Each one is created by a different transaction, often by a different team, and each has its own number.
Without a stored link, you could not answer simple questions. Which delivery belongs to this order? Which invoice billed this delivery? Which journal entry came from this invoice? SAP answers them by saving a reference from each document to the document it came from.
The working model: a chain of reference links
Document flow is the set of those saved references. Each link says "document B was created with reference to document A". Following the links forward gives the successors. Following them backward gives the predecessors.
Three points about this model:
- A link connects a predecessor to a successor. It is created when the successor is saved, not when you later display it.
- The links form a chain, but not always a straight line. One order can have several deliveries, and one invoice can bill several deliveries.
- The links cross module boundaries. The same idea connects SD, MM and FI documents.
Where the links live
SAP does not keep one global link table. The storage depends on the area:
| Area | Where links are stored | What it records |
|---|---|---|
| Sales and distribution | Table VBFA | Preceding and subsequent SD documents |
| Purchasing | Table EKBE | Goods receipts and invoice receipts for a PO |
| Accounting | Reference fields in BKPF | The source transaction and source document key |
Later chapters cover each of these in detail. For now, remember that the display you see in the GUI is assembled from these stored references.
What the stored link contains
A link holds more than two document numbers. It also records the item numbers on both sides and the category of each document, such as order, delivery or invoice. Item-level detail matters because an order with ten items can ship in several parts. The link shows which item went into which delivery.
DATA lv_order TYPE vbeln_va VALUE '0000004711'.
SELECT vbelv, posnv, vbeln, posnn, vbtyp_n
FROM vbfa
WHERE vbelv = @lv_order
INTO TABLE @DATA(lt_followers).Here VBELV and POSNV identify the preceding document and item. VBELN, POSNN and VBTYP_N identify the subsequent document, its item and its category. The query returns the direct successors of the order only. It does not walk the whole chain.
Why it matters in practice
Document flow supports several everyday tasks:
- Audit trail. You can show an auditor how a posting in FI traces back to a customer order.
- Status and completeness. SAP uses the links to decide whether an order is fully delivered or billed.
- Controlling follow-on steps. A document that already has a successor may be blocked from changes or deletion.
- Error analysis. When a billing document is missing, the chain shows where it stopped.
Common mistakes
- Expecting a complete chain from one table. VBFA covers SD documents, while PO history and accounting references are stored elsewhere.
- Reading only the direct links. A query on the order returns the delivery, not the invoice that follows the delivery.
- Treating a missing link as a missing document. The document may exist but have been created without a reference.
Exercise
A sales order has two deliveries, and both were billed in one invoice. Does the document flow still form a single straight line? What does each link record?
Show answer
No. The order has two successors, and the invoice has two predecessors, so the chain branches and then merges. Each link records the preceding and subsequent document numbers, their item numbers and the document category of the successor.
Exercise
Why does a SELECT on VBFA with VBELV set to a sales order not return the accounting document?
Show answer
It returns only the direct successors stored in VBFA, such as the delivery. The accounting document is linked through reference fields in BKPF, so you must follow the chain further and read that table separately.