Sub topic 11
Item-level links, partial deliveries and partial invoices
This chapter assumes you can read VBFA and EKBE in SE16N and that you know the header and item structure of sales documents. Document flow is stored per item, not per document. Partial processing, item splits and collective documents only make sense once you read the links at that level.
Why the item is the unit of flow
A document header says that a sales order exists. The items say what was ordered, and each item can be delivered and billed on its own schedule. For that reason VBFA stores each link as a pair of items:
VBELVandPOSNVidentify the preceding document and its item.VBELNandPOSNNidentify the subsequent document and its item.VBTYP_VandVBTYP_Ngive the document category on each side.RFMNGholds the referenced quantity in the base unit of measure, andMEINSholds that unit.RFWRTholds the referenced value, andPLMINholds the sign of the link.
The GUI display in VBFA-based transactions such as VA03 aggregates these rows. When quantities look wrong, the rows are the ground truth.
A worked example: one item, two deliveries, one invoice
Order 4711 has item 10 for 100 pieces. Stock covers only 40 pieces on the first day, so the warehouse ships 40 now and 60 later. Billing then combines both deliveries into one invoice.
The matching VBFA rows for the delivery and billing links look like this:
| VBELV | POSNV | VBELN | POSNN | VBTYP_N | RFMNG |
|---|---|---|---|---|---|
| 4711 | 000010 | 80001 | 000010 | J | 40 |
| 4711 | 000010 | 80002 | 000010 | J | 60 |
| 80001 | 000010 | 90001 | 000010 | M | 40 |
| 80002 | 000010 | 90001 | 000020 | M | 60 |
Three points follow from these rows:
- The order item has two outgoing links, one per delivery. Partial delivery creates additional rows. It never changes existing rows.
- The invoice item numbers (10 and 20) do not match the delivery item numbers (both 10).
POSNNis the item number in the subsequent document and follows that document's own numbering. - Goods issue posting adds further rows, with
VBTYP_N = 'R'. The delivery is the predecessor and the material document is the successor.
Summing quantities per item
To see how much of each order item has been delivered, aggregate RFMNG by item. This report runs as shown, with the order number filled in:
REPORT z_delivered_qty.
PARAMETERS p_order TYPE vbeln_va DEFAULT '0000004711'.
SELECT posnv, meins, SUM( rfmng ) AS delivered
FROM vbfa
WHERE vbelv = @p_order
AND vbtyp_n = 'J'
GROUP BY posnv, meins
ORDER BY posnv
INTO TABLE @DATA(lt_delivered).
IF lt_delivered IS INITIAL.
WRITE / 'No deliveries found for this order.'.
ELSE.
LOOP AT lt_delivered ASSIGNING FIELD-SYMBOL(<ls_item>).
WRITE: / <ls_item>-posnv, <ls_item>-delivered, <ls_item>-meins.
ENDLOOP.
ENDIF.Two cautions apply when you compare this result with the order quantity:
RFMNGis in the base unit.VBAP-KWMENGis in the sales unit (VRKME). If the two units differ, convert before comparing.- The
GROUP BYincludesMEINSso that rows in different units are never added together.
Changing the predecessor key for billing
The billing link depends on the billing type and on the item's billing relevance.
| Billing method | Predecessor of the invoice item | Typical use |
|---|---|---|
| Delivery-related | Delivery item (category `J`) | Standard goods sales |
| Order-related | Order item (category `C`) | Services, make-to-order, down-payment scenarios |
For delivery-related billing, the invoice quantity is limited by the delivered quantity. For order-related billing, it is limited by the ordered quantity. If a trace seems to skip the delivery, check which method the item category and billing type use, not just which documents exist.
Why item numbers diverge
Several mechanisms break the assumption that item 10 stays item 10.
- Collective invoices. Billing combines items from several deliveries. The invoice numbers its own items, as in the example above.
- Batch split. A delivery item for a batch-managed material can get sub-items, typically numbered from
900001. The sub-items link back to the main item through the higher-level item fieldUEPOSon the delivery item. Quantities in VBFA may sit on the sub-items. - Delivery split. The system can split one order into several deliveries by shipping point, route or other criteria. Each delivery gets its own header, and each carries its own link row from the same order item.
- Bills of material and item hierarchies. Sub-items inherit links from their parent items, and the quantity may be on the parent or on the child depending on configuration.
When you write a trace, always join on both document number and item number. Joining on the document number alone multiplies rows as soon as a document has more than one item.
Schedule lines and what "open" means
Sales order items carry schedule lines (table VBEP). They hold the requested date and the confirmed quantity. A delivery can only be created for confirmed quantity that is due, so an item can show open quantity in the order and still be impossible to deliver. VBFA does not record that. It records only what has already been created. The remaining quantity is the order quantity minus the sum of links, and whether it can be created is a separate question about schedule lines, blocks and availability.
Purchasing: the same idea in EKBE
For purchase orders, the history table EKBE plays the role of VBFA. It is keyed by PO and item (EBELN, EBELP), and each partial goods receipt or invoice receipt adds a row.
DATA lv_po TYPE ebeln VALUE '4500000123'.
SELECT ebelp, vgabe, shkzg, SUM( menge ) AS qty
FROM ekbe
WHERE ebeln = @lv_po
GROUP BY ebelp, vgabe, shkzg
ORDER BY ebelp, vgabe, shkzg
INTO TABLE @DATA(lt_totals).Two fields determine how to read the totals:
VGABEis the transaction type: 1 for goods receipt, 2 for invoice receipt, 3 for subsequent debit or credit.SHKZGis the debit/credit indicator.Sis a debit andHis a credit. A goods receipt reversal appears as anHrow, so a net quantity isSminusH, not a plain sum.
A plain SUM( menge ) without SHKZG therefore overstates what was received whenever a reversal exists.
Common errors
| Symptom | Likely cause | Check |
|---|---|---|
| Delivered quantity exceeds order quantity | Unit mismatch (base unit versus sales unit) | Compare `MEINS` in VBFA with `VRKME` in VBAP |
| Invoice has more items than the delivery | Collective invoice or sub-items from batch split | Look at `UEPOS` and the `POSNN` values |
| Order shows open quantity, but no delivery is possible | No confirmed schedule line, a block, or no stock | Check VBEP and the delivery block |
| PO received quantity too high | Reversal rows counted as receipts | Group by `SHKZG` |
| Trace query returns duplicate rows | Join on document number without item number | Add `POSNV` and `POSNN` to the join |
Exercise
Order 5000 item 20 is for 10 pieces. VBFA shows two delivery links for it, RFMNG = 4 and RFMNG = 3, and one invoice link from the first delivery with RFMNG = 4. How many pieces are still open for delivery, and how many delivered pieces are not yet billed? Which VBFA categories would you filter on?
Show answer
Open for delivery: 10 - (4 + 3) = 3 pieces, assuming all quantities are in the same unit. Delivered but not billed: 3 pieces, which are the second delivery. Filter on VBTYP_N = 'J' for the delivery links from the order item and on VBTYP_N = 'M' for the invoice links from the delivery items. Join on both document and item number.
Exercise
A query on EKBE for PO item 10 returns goods receipt rows with SHKZG = 'S' totalling 100 and rows with SHKZG = 'H' totalling 20. What is the net received quantity, and what does the H total represent?
Show answer
The net received quantity is 100 - 20 = 80. The H rows are credits, which here represent goods receipt reversals or returns to the vendor. They reduce the quantity received.