# SAP PM Order Status Table Query Generator (JEST, TJ02T, STATUS_TEXT_EDIT)

> Source: https://netray.co/tools/sap-ecc-object-status-jest-tj02t-abap-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in plant, order type and the statuses to include and exclude, and get a working ABAP report that reads AUFK, JEST, TJ02T and TJ30T and prints the status line with STATUS_TEXT_EDIT.

## Category

developer

## Erp

SAP ECC 6.0

## Audience

- ABAP developer
- SAP PM consultant
- SAP PP consultant

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Plant (AUFK-WERKS)

**Key:** werks

**Type:** text

**Default:** 1000

#### Order category (AUFK-AUTYP)

**Key:** autyp

**Type:** select

**Options:**

- 30
- 10
- 40

**Default:** 30

**Help:** 30 maintenance order, 10 production order, 40 process order.

#### Order type (AUFK-AUART)

**Key:** auart

**Type:** text

**Default:** PM01

#### System status to include (TJ02T-TXT04, English)

**Key:** incl

**Type:** text

**Default:** TECO

#### System status to exclude (TJ02T-TXT04, English)

**Key:** excl

**Type:** text

**Default:** CLSD

#### Created on or after (YYYYMMDD)

**Key:** erdat

**Type:** text

**Default:** 20260101

**Blocks:**

#### Report header, declarations and selection screen

**Body:** REPORT zpm_order_status_list.

* Orders in plant {{werks}}, category {{autyp}}, type {{auart}}
* with active system status {{incl}} and without active status {{excl}}.
* 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 '{{werks}}' OBLIGATORY,
            p_autyp TYPE aufk-autyp  DEFAULT '{{autyp}}' OBLIGATORY,
            p_auart TYPE aufk-auart  DEFAULT '{{auart}}' OBLIGATORY,
            p_incl  TYPE tj02t-txt04 DEFAULT '{{incl}}' OBLIGATORY,
            p_excl  TYPE tj02t-txt04 DEFAULT '{{excl}}',
            p_erdat TYPE aufk-erdat  DEFAULT '{{erdat}}'.

#### Selection: AUFK joined to JEST, exclusion by NOT EXISTS

**Body:** 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

**Body:**   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)

**Body:** * 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.

**Notes:** 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.

## Content

**Intro:** 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.

**Sections:**

#### Where order status lives in SAP ECC

**Body:** 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.

**Bullets:**

- 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

**Body:** 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

**Body:** 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

**Body:** 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.

**Cta:** 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.

**Faq:**

#### Which table stores PM order status in SAP?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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.

## Search terms

sap pm order status table, sap pm order system status table, pm order status table in sap, sap pm order system status codes, jest table in sap, tj02t table sap, status_text_edit function module, sap user status table tj30t

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
