SAP Process Order ABAP SELECT Snippet Generator
Process orders in SAP PP-PI are stored across the order master AUFK, the PP header AFKO and the order item AFPO. This generator builds an ABAP SELECT that joins the three tables for a plant and order type, giving a starting point for a quick report or a data extract.
Fill in
Use the order type configured in your system.
Process order list
* Process orders (order category 40) joined across header and item
TYPES: BEGIN OF ty_po,
aufnr TYPE aufk-aufnr,
auart TYPE aufk-auart,
werks TYPE aufk-werks,
gstrp TYPE afko-gstrp,
gltrp TYPE afko-gltrp,
gamng TYPE afko-gamng,
gmein TYPE afko-gmein,
matnr TYPE afpo-matnr,
psmng TYPE afpo-psmng,
wemng TYPE afpo-wemng,
END OF ty_po.
DATA lt_po TYPE STANDARD TABLE OF ty_po WITH EMPTY KEY.
DATA lv_matnr TYPE afpo-matnr VALUE '[Material number (MATNR) or blank]'.
SELECT k~aufnr, k~auart, k~werks,
o~gstrp, o~gltrp, o~gamng, o~gmein,
p~matnr, p~psmng, p~wemng
FROM aufk AS k
INNER JOIN afko AS o ON o~aufnr = k~aufnr
INNER JOIN afpo AS p ON p~aufnr = k~aufnr
WHERE k~autyp = '40'
AND k~werks = '1000'
AND k~auart = 'YBM1'
AND o~gstrp >= '20261001'
AND k~loekz = ''
ORDER BY o~gstrp, k~aufnr
INTO CORRESPONDING FIELDS OF TABLE @lt_po
UP TO 500 ROWS.
IF lv_matnr IS NOT INITIAL.
DELETE lt_po WHERE matnr <> lv_matnr.
ENDIF.
IF sy-subrc <> 0 OR lt_po IS INITIAL.
WRITE: / 'No process orders found'.
ENDIF.Output loop for a quick test
LOOP AT lt_po ASSIGNING FIELD-SYMBOL(<po>). WRITE: / <po>-aufnr, <po>-matnr, <po>-gstrp, <po>-psmng, <po>-gmein. ENDLOOP.
Verify field names and the order category on your release: AUTYP 40 identifies process orders in standard systems. In S/4HANA, check for custom views and authorization needs, add an authority check for plant (C_AFKO_ATY or your standard), and never run unrestricted selects in production dialog sessions.
Process order data without ABAP
Ask how a read-only AI layer over SAP PP-PI could answer order status questions without a custom report for each one.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the plant, process order type and the earliest scheduled start date in the form YYYYMMDD, then copy the generated code into a test report or a local class. The query filters on order category 40, which identifies process orders, and excludes orders flagged for deletion. The optional material filter is applied after the select, which is simple but not optimal for large volumes, so add it to the WHERE clause if you only ever need one material.
- Test in a development or quality client first
- Add a plant authority check before using it in a real report
- Use the row limit while exploring the data
What each table holds
AUFK is the order master shared by all order types and holds the order number, order type, plant and status-related object number. AFKO holds the production order header data, including basic dates such as GSTRP and GLTRP and the total order quantity GAMNG. AFPO holds item-level data, including the material, planned quantity PSMNG and the delivered quantity WEMNG. Status details sit in the object status tables and are normally read with standard function modules rather than direct selects.
Common mistakes
Frequent issues are forgetting the order category and accidentally mixing in production orders, using a date field type that does not match the stored format, and joining without considering multiple items per order. For released status, confirmations or batch details, use the standard function modules or CDS views where available, since table logic can be incomplete. In S/4HANA, check whether released views or APIs already provide what you need.
- Do not rely on direct reads for status logic
- Remember the date format is YYYYMMDD in character fields
- Check for multiple items on the same order
Frequently Asked Questions
Which tables store SAP process orders?
The common ones are AUFK for the order master, AFKO for the PP header with dates and quantities, and AFPO for the order item with material. Components are in RESB and operations in AFVC and AFVV, reached through the routing link in AFKO.
How do I tell process orders from production orders?
Use the order category in AUFK-AUTYP. In standard SAP, 10 is a production order and 40 is a process order. Order types in AUART are customizing, so they differ between companies.
Can I use this in S/4HANA?
The tables still exist in S/4HANA and the syntax works with the modern ABAP release. Check released CDS views and APIs for new developments and respect authorization checks and performance guidelines.
Why is the status of the order not in the select?
System and user status are held in separate status tables linked by the object number, and are better read with standard function modules. Mixing them into a custom join is possible but easy to get wrong.
If you need process order reporting or an AI assistant over SAP PP-PI data without writing ABAP for each question, Netray can discuss a read-only approach that respects SAP roles.
Related Tools
SAP Batch Shelf Life Expiry Stock SQL Query Generator (MCH1, MCHB)
Build a SQL query that lists batches whose shelf life expiry date falls in a chosen window, with stock by status, for chemical and specialty products.
Industry TemplatesChemical Batch Manufacturing Record Template
A fill-in batch record with raw material charges, process steps, in-process checks, yield and review signatures. Exports to PDF, Word or Excel.
Industry TemplatesChemical Batch Yield and Mass Balance Calculator
Calculates theoretical yield from the limiting reagent, actual yield percent corrected for purity, and the unaccounted mass in a batch.
Developer ToolsSAP ABAP AUTHORITY-CHECK Snippet Generator
Fill in an authorization object, activity and organisational field and get a ready ABAP AUTHORITY-CHECK block with error handling.