SAP S/4HANA Production Order Tables: AUFK, AFKO, AFPO, AFVC, RESB and Join SQL
The main SAP S/4HANA production order tables are AUFK (order master), AFKO (header), AFPO (item), AFVC and AFVV (operations), and RESB (components). The generator below joins them with your plant, order type and date range so you can copy working SQL.
Fill in
Order types are configured per system; PP01 is the common standard sample.
Use the internal format with leading zeros if your material numbers are numeric.
1. Which tables hold a production order
-- AUFK : order master (all order categories). Key AUFNR. AUTYP = '10' is a production order. -- AFKO : order header for PP (dates GSTRP/GLTRP, order quantity GAMNG, AUFPL routing link, RSNUM reservation). -- AFPO : order item (MATNR, PSMNG planned qty, WEMNG delivered qty, MEINS, DWERK). -- AFVC : operations (key AUFPL + APLZL). AFVV holds operation quantities and dates, same key. -- RESB : components / reservation items (RSNUM + RSPOS). RESB-AUFNR also holds the order number. -- JEST : status per object. AUFK-OBJNR links to JEST-OBJNR. Active status has INACT = ' '.
2. Order headers in a plant and period
SELECT k.AUFNR, k.AUART, k.WERKS, p.MATNR, p.PSMNG, p.WEMNG, p.MEINS,
o.GSTRP AS BASIC_START, o.GLTRP AS BASIC_FINISH, k.OBJNR
FROM AUFK k
JOIN AFKO o ON o.MANDT = k.MANDT AND o.AUFNR = k.AUFNR
JOIN AFPO p ON p.MANDT = o.MANDT AND p.AUFNR = o.AUFNR
WHERE k.MANDT = '100'
AND k.AUTYP = '10'
AND k.WERKS = '1000'
AND k.AUART = 'PP01'
AND o.GSTRP BETWEEN '20260101' AND '20261231'
-- exclude deletion-flagged orders (I0013) and closed orders (I0046)
AND NOT EXISTS (
SELECT 1 FROM JEST j
WHERE j.MANDT = k.MANDT AND j.OBJNR = k.OBJNR
AND j.STAT IN ('I0013', 'I0046') AND j.INACT = ' ')
ORDER BY o.GSTRP, k.AUFNR;3. Operations for those orders
SELECT k.AUFNR, v.VORNR AS OPERATION, v.ARBID, v.STEUS AS CONTROL_KEY,
v.LTXA1 AS OP_TEXT, w.MGVRG AS OP_QTY, w.VGW01 AS STANDARD_VALUE_1
FROM AUFK k
JOIN AFKO o ON o.MANDT = k.MANDT AND o.AUFNR = k.AUFNR
JOIN AFVC v ON v.MANDT = o.MANDT AND v.AUFPL = o.AUFPL
JOIN AFVV w ON w.MANDT = v.MANDT AND w.AUFPL = v.AUFPL AND w.APLZL = v.APLZL
WHERE k.MANDT = '100'
AND k.AUTYP = '10'
AND k.WERKS = '1000'
AND k.AUART = 'PP01'
AND o.GSTRP BETWEEN '20260101' AND '20261231'
ORDER BY k.AUFNR, v.VORNR;4. Components (reservation items) of the orders
SELECT k.AUFNR, r.RSPOS, r.MATNR AS COMPONENT, r.BDMNG AS REQ_QTY,
r.ENMNG AS WITHDRAWN_QTY, r.MEINS, r.LGORT, r.VORNR AS OPERATION
FROM AUFK k
JOIN AFKO o ON o.MANDT = k.MANDT AND o.AUFNR = k.AUFNR
JOIN RESB r ON r.MANDT = o.MANDT AND r.RSNUM = o.RSNUM
WHERE k.MANDT = '100'
AND k.AUTYP = '10'
AND k.WERKS = '1000'
AND r.XLOEK = ' '
AND r.MATNR = 'FG-10045'
ORDER BY k.AUFNR, r.RSPOS;5. Status codes used above
| JEST status | Meaning | Short text |
|---|---|---|
| I0001 | Created | CRTD |
| I0002 | Released | REL |
| I0009 | Confirmed | CNF |
| I0010 | Partially confirmed | PCNF |
| I0012 | Delivered | DLV |
| I0013 | Deletion flag | DLFL |
| I0045 | Technically completed | TECO |
| I0046 | Closed | CLSD |
Check field names on your release in SE11 before running. Run in the SAP HANA SQL console or a replicated copy, not against production during peak load. Goods movements for orders are read from MATDOC in S/4HANA; the old AUFM table is replaced by a compatibility view. Custom statuses and order types differ per system.
Production order questions answered from SAP
Optional: see how planners can ask about orders, components and delays in plain language over your own SAP data.
Optional. The tool and every export work without this. No spam.
How the production order tables fit together
AUFK is shared by all order types, so always filter AUTYP = '10' to get production orders (process orders use a different category and network and maintenance orders have their own). AFKO and AFPO share the order number AUFNR with AUFK. AFKO carries the routing link AUFPL, which is the key into the operations in AFVC and AFVV, and the reservation number RSNUM, which is the key into the components in RESB. The status lives in JEST, found through the OBJNR on AUFK.
- AUFK to AFKO to AFPO on AUFNR
- AFKO-AUFPL to AFVC-AUFPL, then AFVV on AUFPL and APLZL
- AFKO-RSNUM to RESB-RSNUM for components
- AUFK-OBJNR to JEST-OBJNR for status
What changed in S/4HANA
The order tables themselves are unchanged, which is why this SQL also works on ECC. What changed is around them: material documents are stored in MATDOC rather than MKPF and MSEG, the old AUFM goods movement table is a compatibility view, and cost postings are in ACDOCA. If your report reads order goods issues or receipts, move it to MATDOC and test against a known order. Also remember that orders created through Fiori apps still write to the same tables.
Reading the result
In the header query, PSMNG is the planned quantity and WEMNG the quantity delivered to stock, so PSMNG minus WEMNG is the open quantity. In the component query, BDMNG is the requirement and ENMNG the quantity already withdrawn. Set the date range to the basic start date; if you want the scheduled dates after rescheduling use the scheduled start fields in AFKO instead. Compare the row count with the order list in COOIS before using the output.
Common mistakes
Joining AFVC on AUFNR does not work, because operations are keyed by AUFPL and APLZL. Forgetting MANDT in each join slows the query and can mix clients. Not filtering the deletion flag returns orders users believe are gone. Many reports also forget that one order can have several AFPO items for co-products, which multiplies the row count in joins. Always aggregate after the join, not before.
Frequently Asked Questions
What is the production order table in SAP S/4HANA?
AUFK is the order master, AFKO the PP header, and AFPO the item with material and quantity. Operations are in AFVC and AFVV, components in RESB, and status in JEST. These tables are the same in ECC and S/4HANA.
How do I join AFKO and AFPO?
Join on MANDT and AUFNR. AUFK also has AUFNR, so the full chain is AUFK to AFKO to AFPO. Use AUFK-AUTYP = '10' to keep only production orders and remember that co-products can create more than one AFPO item per order.
Where are production order components stored?
In RESB, the reservation items. Join AFKO-RSNUM to RESB-RSNUM, or use RESB-AUFNR directly. BDMNG is the required quantity and ENMNG the withdrawn quantity. Skip deleted items with XLOEK blank.
How do I check if an order is released or TECO?
Read JEST with the OBJNR of the order. I0002 means released and I0045 means technically completed. A status counts only when INACT is blank. The texts are in table TJ02T, with REL and TECO as short codes.
If planners keep asking for new cuts of production order data, we can set up a private AI layer on your SAP data that writes and shows the query for them, read-only, hosted on-prem if required.
Related Tools
SAP PP Database Tables Reference
A lookup of the main SAP PP database tables, what each holds and the key fields to join on.
SAPSAP Open Production Orders ABAP SELECT Generator
Fill in plant, order type and dates and get a ready ABAP Open SQL query for open production orders.
SAPSAP Production Order Types, Categories and Statuses Reference
A searchable lookup of SAP order categories, order type controls, system statuses, shop floor transactions and core order tables.
SAPSAP PP Transaction Codes Reference
A searchable cheat sheet of the SAP PP transaction codes planners and consultants use every day, grouped by area.
More SAP tools
See allKeep exploring
Free tools
- SAP Manufacturing Order Table Join SQL GeneratorGenerates SQL that joins the SAP production order header, item and component tables with the correct keys, plus a field guide to each table.
- SAP PP Database Tables ReferenceA lookup of the main SAP PP database tables, what each holds and the key fields to join on.
- SAP MM Table Relationships and Join Keys ReferenceA searchable relationship map of SAP MM tables listing the join keys between purchasing, goods movement, invoice, material master and cost center tables.