SAP PM Order Status Table Query Generator (JEST, TJ02T, STATUS_TEXT_EDIT)
This generator writes an ABAP report for SAP ECC 6.0 that lists maintenance, production or process orders by system status, for example everything technically completed (TECO) but not yet closed (CLSD). It reads AUFK, JEST and TJ02T directly and prints the readable status line with STATUS_TEXT_EDIT.
Fill in
30 maintenance order, 10 production order, 40 process order.
Report header, declarations and selection screen
REPORT zpm_order_status_list.
* Orders in plant 1000, category 30, type PM01
* with active system status TECO and without active status CLSD.
* Internal status examples (check TJ02T in your system):
* I0001 CRTD I0002 REL I0045 TECO I0046 CLSD I0076 DLFL
TYPES: BEGIN OF ty_obj,
aufnr TYPE aufk-aufnr,
auart TYPE aufk-auart,
objnr TYPE aufk-objnr,
END OF ty_obj.
DATA: gt_obj TYPE STANDARD TABLE OF ty_obj,
gs_obj TYPE ty_obj,
gv_incl TYPE tj02t-istat,
gv_excl TYPE tj02t-istat,
gv_line TYPE bsvx-sttxt,
gv_user TYPE bsvx-sttxt.
PARAMETERS: p_werks TYPE aufk-werks DEFAULT '1000' OBLIGATORY,
p_autyp TYPE aufk-autyp DEFAULT '30' OBLIGATORY,
p_auart TYPE aufk-auart DEFAULT 'PM01' OBLIGATORY,
p_incl TYPE tj02t-txt04 DEFAULT 'TECO' OBLIGATORY,
p_excl TYPE tj02t-txt04 DEFAULT 'CLSD',
p_erdat TYPE aufk-erdat DEFAULT '20260101'.Selection: AUFK joined to JEST, exclusion by NOT EXISTS
START-OF-SELECTION.
* Translate the English 4-character texts to internal numbers once,
* so the main query does not depend on the logon language.
SELECT SINGLE istat FROM tj02t INTO gv_incl
WHERE spras = 'E'
AND txt04 = p_incl.
IF sy-subrc <> 0.
MESSAGE 'Include status not found in TJ02T' TYPE 'E'.
ENDIF.
IF p_excl IS NOT INITIAL.
SELECT SINGLE istat FROM tj02t INTO gv_excl
WHERE spras = 'E'
AND txt04 = p_excl.
ENDIF.
* JEST-INACT = space means the status is currently active.
SELECT a~aufnr a~auart a~objnr
INTO TABLE gt_obj
FROM aufk AS a
INNER JOIN jest AS j ON j~objnr = a~objnr
WHERE a~werks = p_werks
AND a~autyp = p_autyp
AND a~auart = p_auart
AND a~erdat >= p_erdat
AND j~stat = gv_incl
AND j~inact = space
AND NOT EXISTS ( SELECT objnr FROM jest
WHERE objnr = a~objnr
AND stat = gv_excl
AND inact = space ).Output: full system and user status line with STATUS_TEXT_EDIT
LOOP AT gt_obj INTO gs_obj.
CLEAR: gv_line, gv_user.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
flg_user_stat = 'X'
objnr = gs_obj-objnr
only_active = 'X'
spras = sy-langu
IMPORTING
line = gv_line
user_line = gv_user
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
WRITE: / gs_obj-aufnr, gs_obj-auart, gv_line, gv_user.
ENDIF.
ENDLOOP.Optional: user status codes in SQL (JSTO + TJ30T)
* User statuses are E-numbers in JEST-STAT. The status profile
* comes from JSTO-STSMA; texts are in TJ30T by profile and language.
TYPES: BEGIN OF ty_ustat,
objnr TYPE jest-objnr,
stat TYPE jest-stat,
txt04 TYPE tj30t-txt04,
END OF ty_ustat.
DATA gt_ustat TYPE STANDARD TABLE OF ty_ustat.
IF gt_obj IS NOT INITIAL.
SELECT j~objnr j~stat t~txt04
INTO TABLE gt_ustat
FROM jest AS j
INNER JOIN jsto AS s ON s~objnr = j~objnr
INNER JOIN tj30t AS t ON t~stsma = s~stsma
AND t~estat = j~stat
FOR ALL ENTRIES IN gt_obj
WHERE j~objnr = gt_obj-objnr
AND j~inact = space
AND t~spras = sy-langu.
ENDIF.Verify in SE11/SE16 on your system: the I-numbers in TJ02T for the texts you use (TXT04 is unique per language in standard, but check custom languages), and that STATUS_TEXT_EDIT in SE37 has OBJNR, SPRAS, FLG_USER_STAT and ONLY_ACTIVE as importing parameters and LINE and USER_LINE (BSVX-STTXT) as exporting parameters. The same JEST pattern works for notifications (QMEL-OBJNR) and inspection lots (QALS-OBJNR); swap the driving table and its plant field.
Need a status report built for your status profiles?
Send us your order types and user status profiles and we will review the generated report against your ECC system's TJ02T and TJ30T entries.
Optional. The tool and every export work without this. No spam.
Where order status lives in SAP ECC
Orders do not store status in AUFK. Each order has an object number, AUFK-OBJNR, and every status ever set on that object is a row in JEST (OBJNR, STAT, INACT, CHGNR). STAT holds an internal number: I-numbers are system statuses, E-numbers are user statuses. JEST-INACT is blank when the status is active and X when it was later reset, so a status filter must always include INACT = space. Texts for system statuses are in TJ02T (ISTAT, SPRAS, TXT04, TXT30). User statuses depend on the status profile, which is stored per object in JSTO-STSMA, with texts in TJ30T keyed by STSMA, ESTAT and SPRAS. The change history sits in JCDS.
- AUFK-OBJNR to JEST-OBJNR: one row per status per object
- JEST-STAT I0045 with INACT blank: TECO is active
- TJ02T: system status texts, TJ30T: user status texts by profile
- JSTO-STSMA: status profile assigned to the object
How the generated report works
The report first converts your four-character texts (TECO, CLSD) into internal numbers by reading TJ02T in English, so the main query runs on numbers and gives the same result whatever language the user logs on in. It then joins AUFK to JEST on OBJNR for the include status and uses a correlated NOT EXISTS subquery on JEST for the exclude status. Both checks require INACT = space. For each hit it calls STATUS_TEXT_EDIT with FLG_USER_STAT = X to get the same status line you see on the IW33 or CO03 header, plus the user status line. The last block shows how to read user statuses in pure SQL through JSTO and TJ30T, which is what you need for a CDS view or an extract.
Worked example: TECO orders that are still open
Plant 1000, order category 30, type PM01, include TECO, exclude CLSD, created from 1 January 2026. The report returns maintenance orders whose technical completion is active and which have not been business-completed, the typical month-end list for controlling before settlement and closing in KO8G or IW38. Change the include status to REL and the exclude to TECO to see released orders not yet completed. To catch orders flagged for deletion, include DLFL. For production orders use category 10 and a type such as PP01; the status logic is identical because production orders also use AUFK-OBJNR.
Common mistakes
The most frequent bug is forgetting INACT, which returns orders where TECO was set and later revoked. The second is filtering on TJ02T-TXT04 with SY-LANGU: in German the texts differ, so a report written in English returns nothing for a German user. The third is calling STATUS_TEXT_EDIT inside a loop over tens of thousands of orders without restricting the selection first; the function reads status buffers per object, so narrow by plant, type and date before you loop. Finally, do not hard-code E-numbers across profiles: E0001 in one status profile is unrelated to E0001 in another, which is why TJ30T is keyed by STSMA.
Frequently Asked Questions
Which table stores PM order status in SAP?
Table JEST stores the status of PM orders, production orders, notifications and other objects, keyed by object number (OBJNR) and status (STAT). Link it to the order through AUFK-OBJNR. System status texts are in TJ02T and user status texts in TJ30T. JCDS keeps the change documents with dates and users.
What are the SAP PM order system status codes for TECO and CLSD?
In standard SAP the internal number for TECO (technically completed) is I0045 and for CLSD (closed) is I0046. CRTD is I0001, REL is I0002 and DLFL (deletion flag) is I0076. Always confirm in TJ02T on your system before hard-coding a number, and filter JEST with INACT blank so only active statuses count.
What does JEST-INACT mean?
INACT is the inactive indicator. When a status is set, JEST gets a row with INACT blank. When the status is reset, for example TECO is revoked, the row stays but INACT becomes X. A report that ignores INACT will treat revoked statuses as active, which is a common source of wrong month-end lists.
Is there a batch job status table in SAP like JEST?
No. Background job status is not held in JEST. Job headers, including the status field, are in TBTCO, job steps in TBTCP, and you view them in SM37. JEST is only for business objects with an object number, such as orders, notifications, inspection lots, WBS elements and equipment.
If you want planners and controllers to ask your ECC system questions like this in plain English on your own servers, we can set up a private AI layer that runs the same JEST logic read-only.
Related Tools
SAP PM Order and Notification Status Reference
A lookup of SAP PM system statuses with what each means, what sets it and what it blocks.
Developer ToolsSAP ECC SD Document Flow ABAP Generator (VBFA, VBUK, VBUP)
Enter a sales order and the follow-on document categories you want, and get an ABAP report that reads VBFA from order to delivery to invoice and goods movement, with VBUK and VBUP status.
Developer ToolsSAP ECC BAdI Implementation Method Code Generator (ME_PROCESS_PO_CUST, MB_MIGO_BADI, WORKORDER_UPDATE)
Pick a plant, the field that must be filled and your message class, and get ready-to-paste method code for three common ECC classic BAdIs, with the SE19 steps.
SAPSAP ECC Job Log, Spool and TBTCO Growth Housekeeping Calculator
Enter jobs per day, steps, spool share, average sizes and retention days to see how many job and spool rows you keep and how much TemSe storage they use in the database or file system.
More Developer Tools tools
See all- SAP ECC Enhancement Transactions and Exit Tables Reference (SMOD, CMOD, SE18, MODSAP, SXC_EXIT)
- SAP ECC Data Dictionary and Repository Tables Reference (DD02L, DD03L, T100, E070, TSTC)
- SAP ECC ABAP Runtime Errors (ST22 Dumps) and Error Log Transactions Reference
- SAP ECC Background Job History ABAP Query Generator (TBTCO + TBTCP)
- SAP ECC Background Job Creation ABAP Generator (JOB_OPEN, SUBMIT, JOB_CLOSE)
- SAP ECC IDoc Segment Data Reader ABAP Generator (EDIDC, EDID4, EDIDS)
- SAP ECC Custom Inbound IDoc Function Module Skeleton Generator
- SAP ECC BAPI_SALESORDER_CHANGE ABAP Generator
- SAP ECC BAPI_PO_CHANGE ABAP Generator
Keep exploring
Free tools
- SAP ECC BAPI_PO_CHANGE ABAP GeneratorGenerate a working ABAP program that changes an SAP purchase order item with BAPI_PO_CHANGE, with POITEM/POITEMX, schedule line date conversion, test run and commit handling.
- SAP ECC BAPI_MATERIAL_SAVEDATA Material Creation ABAP GeneratorFill in material type, plant, sales and valuation data and get a complete ABAP report that creates the material with BAPI_MATERIAL_SAVEDATA and commits it.
- SAP ECC BAPI_SALESORDER_CHANGE ABAP GeneratorGenerate a working ABAP program that updates an SAP sales order with BAPI_SALESORDER_CHANGE, with the correct X structures, schedule line handling, error check and commit or rollback.
ERP fixes and how-tos
- How to add AI to SAP ECC 6.0 on-prem without moving data to a cloudReference architecture for a private on-prem AI assistant on SAP ECC 6.0: RFC and BAPI reads, SLT replica, retrieval index, local LLM, permission mirroring.
- How to Use BAPI_TRANSACTION_COMMIT CorrectlyBAPIs never commit their own update. Here is when to call BAPI_TRANSACTION_COMMIT with WAIT, and why a BAPI can run fine and still save nothing.
- How to Create a Status Profile in SAP QM (BS02)Create a user status profile in SAP QM with BS02 and assign it to quality notifications, tasks and inspection lots, with status numbers and business transaction control.
Integrations
- How to add WhatsApp to SAP ECC 6.0How to connect WhatsApp Business to SAP ECC 6.0 using BAPIs, IDocs and output determination: order status, shipment alerts, approvals and supplier replies.
- How to use ChatGPT with SAP ECC 6.0Using ChatGPT with SAP ECC 6.0: custom GPT actions, exports versus live access, an OData or MCP bridge, enterprise data controls, and when a private model is safer.