In SAP S/4HANA, one sales order item can have several schedule lines, several outbound delivery items and several billing items. Summarize requested and delivered quantities to the order item before joining them, and use the delivery item’s reference to the order item as the link. Compare quantities in the same unit. A delivery that exists has not necessarily left the warehouse, so check goods movement status, and treat billing as a separate question.
A hundred units that became 140
Take a synthetic case. Order item 10 requests 100 units. Two deliveries ship 40 and 30, leaving 30 outstanding. Each delivery is billed in two parts, so there are four billing rows. Join order item to delivery item to billing item and sum the delivered quantity, and you get 40 + 40 + 30 + 30, which is 140. On a report this reads as an over-delivery of 40 percent on an order that is still 30 short.
Nothing in the source data is wrong, and no SQL error is raised. The fan-out comes from counting a delivery-level measure at billing grain. Hand a model a sales schema and an open-order question and this is the standard failure. The cure is equally standard: one summary per order item for each measure, joined afterward.
The objects and the fields that link them
SAP’s released APIs give you names you can trust further than a guess at table contents. The Sales Order service has A_SalesOrderItem, keyed by SalesOrder and SalesOrderItem, with RequestedQuantity and a rejection reason in SalesDocumentRjcnReason. The Outbound Delivery service has A_OutbDeliveryItem, keyed by DeliveryDocument and DeliveryDocumentItem. ReferenceSDDocument and ReferenceSDDocumentItem on that item point back to the order item the delivery refers to, and that pair is your join.
On classic ECC and on-premise systems the same concepts appear in tables widely described in SAP community material: VBAK and VBAP for order header and item, VBEP for schedule lines, LIKP and LIPS for delivery header and item, VBRK and VBRP for billing, and VBFA for document flow. The same grain rules apply to replicas of those tables. Be aware that the billing item’s reference fields point at the preceding document, which community answers describe as the delivery for delivery-related billing, so a billing item may have no direct key to the order item. Check on your own documents before you assume it.
Edition matters as well. API availability differs between S/4HANA Cloud and on-premise and between releases, and your connection may see only some of them. Ask the owner which released API or view your team may use, then confirm the fields in its metadata. Field lists in this post were checked against SAP Help and SAP Cloud SDK documentation and should still be read as a starting point for your system.
WITH ordered AS (
SELECT SalesOrder, SalesOrderItem,
SUM(RequestedQuantity) AS requested_qty
FROM a_salesorderitem
WHERE SalesDocumentRjcnReason IS NULL
OR SalesDocumentRjcnReason = ''
GROUP BY SalesOrder, SalesOrderItem
),
shipped AS (
SELECT i.ReferenceSDDocument AS SalesOrder,
i.ReferenceSDDocumentItem AS SalesOrderItem,
SUM(i.ActualDeliveryQuantity) AS delivered_qty
FROM a_outbdeliveryitem i
JOIN a_outbdeliveryheader h ON h.DeliveryDocument = i.DeliveryDocument
WHERE h.ActualGoodsMovementDate IS NOT NULL -- goods have moved
GROUP BY i.ReferenceSDDocument, i.ReferenceSDDocumentItem
)
SELECT o.SalesOrder, o.SalesOrderItem, o.requested_qty,
COALESCE(s.delivered_qty, 0) AS delivered_qty,
o.requested_qty - COALESCE(s.delivered_qty, 0) AS outstanding_qty
FROM ordered o
LEFT JOIN shipped s
ON s.SalesOrder = o.SalesOrder AND s.SalesOrderItem = o.SalesOrderItem;
-- Check your unit handling. Item numbers may need padding to match.
-- Keep deliveries with no matching order item in a separate list.Quantities that look comparable and are not
SAP’s delivery item carries more than one quantity. ActualDeliveryQuantity is documented as the quantity delivered in sales units, while ActualDeliveredQtyInBaseUnit holds it in the base unit. Suppose an order item requests 10 cartons, a carton holds 12 pieces, and a delivery ships 6 cartons. In this synthetic case, comparing the requested 10 with a base-unit figure of 72 reports a massive over-delivery. Comparing with 6 shows 4 outstanding. Use the sales-unit figure against RequestedQuantity, and verify on each row that DeliveryQuantityUnit agrees with the requested unit, which SAP examples show as RequestedQuantityISOUnit on the order item. Where units differ, take the conversion from master data and don’t hard-code a factor.
Summing across a customer or product group has its own hazard. Cartons, kilograms and pallets don’t add. An overall fulfillment rate is better calculated at item level and then averaged in a stated way, or measured by value with a clearly defined price basis. Line fill and quantity fill are different measures, and each suits a different decision.
Which status means shipped
Creating an outbound delivery is a step toward shipping and does not prove shipping. SAP’s outbound delivery header carries OverallGoodsMovementStatus, which the Cloud SDK describes as indicating if, and to what extent, the delivery has left your premises, along with ActualGoodsMovementDate. Picking can be complete with goods still in the warehouse. A planner asking what has left the building needs goods movement. A planner asking what is committed to a delivery needs a count of created deliveries, with the measure named accordingly. The decision below separates these questions, because the most common defect is one column called status answering all of them.
Exceptions that change the queue
Rejected items are the first one to test. SAP’s API examples show that the rejection reason on an already delivered item can’t be changed, and the request still returns success with a message in the response header. A partially delivered item with a rejected remainder needs a rule. It may leave zero outstanding on an item that never fully shipped, and a planner should not chase it, while a customer service report may want it counted as a shortfall.
Returns should be kept apart too. A return document is its own flow, so netting it against delivered quantity answers a different question from what has been shipped. Lateness adds a further choice: schedule lines hold dates, and a revised date can make a late item look on time. Decide whether you are measuring against the first promise or the latest one, and record that in the measure’s name. Your operations owner should decide this, since it changes which team looks bad.
For promised dates, SAP describes a separate Sales Document Schedule Line view, and its Sales Document Item view is meant for questions such as order quantity and confirmed delivery quantity, so one item can carry a requested figure and a confirmed figure that differ. Say which one the shortfall is measured against.
Item-number formats can cause misses nobody sees, too. Reference fields on deliveries may be formatted differently from order item numbers in an extract, for example with leading zeros. A left join that fails on format makes every line look undelivered. Count the matches right after building the join, and look at any large group of outstanding items with no deliveries at all.
A small pilot before you trust any of it
Choose one sales organization and about 20 order items with known outcomes: fully delivered, partial, delivered but not goods-issued, mixed units, rejected remainder, multiple billing rows. Have a planner write the expected outstanding quantity for each. Then ask the AI analytics tool in front of you, ours if that’s the one, which order items are still short.
Read the generated query as well as the result. It should aggregate before joining, use a consistent unit and state what shipped means. An answer with 140 delivered against 100 requested should send you to the documents. It shouldn’t become a chart. You can look up systems to bring to that test in the catalog at nexatron.io/connectors.
Bring three business questions
Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.