SAP Change Number BOM ABAP SELECT Generator (AENR, MAST, STPO)
Engineers and planners often need a list of every BOM item touched by a single SAP engineering change number. The standard transactions answer it one material at a time. This generator gives you an ABAP starting point that reads MAST, STPO and the change master AENR in one pass.
Fill in
Engineering change number from the change master.
1 is commonly production, check your configuration.
Report skeleton
REPORT ZENG_CHANGE_BOM_ITEMS.
PARAMETERS: p_aennr TYPE aennr DEFAULT 'ECN0004711',
p_werks TYPE werks_d DEFAULT '1000',
p_stlan TYPE stlan DEFAULT '1'.
TYPES: BEGIN OF ty_item,
matnr TYPE matnr,
werks TYPE werks_d,
stlan TYPE stlan,
stlnr TYPE stnum,
stlal TYPE stalt,
stlkn TYPE stlkn,
idnrk TYPE idnrk,
menge TYPE kmpmg,
meins TYPE kmpme,
aennr TYPE aennr,
datuv TYPE datuv,
lkenz TYPE lkenz,
END OF ty_item.
DATA lt_items TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY.Select BOM items for the change number
SELECT m~matnr, m~werks, m~stlan, m~stlnr, m~stlal,
p~stlkn, p~idnrk, p~menge, p~meins,
p~aennr, p~datuv, p~lkenz
FROM mast AS m
INNER JOIN stpo AS p
ON p~stlty = 'M'
AND p~stlnr = m~stlnr
WHERE m~werks = @p_werks
AND m~stlan = @p_stlan
AND p~aennr = @p_aennr
ORDER BY m~matnr, p~stlkn
INTO CORRESPONDING FIELDS OF TABLE @lt_items.
IF sy-subrc <> 0.
WRITE: / 'No BOM items found for change number', p_aennr.
RETURN.
ENDIF.Read change master data
SELECT SINGLE aennr, datuv, aenst, aegru
FROM aenr
WHERE aennr = @p_aennr
INTO @DATA(ls_aenr).
WRITE: / 'Change number:', ls_aenr-aennr,
/ 'Valid from:', ls_aenr-datuv,
/ 'Status:', ls_aenr-aenst,
/ 'Reason:', ls_aenr-aegru.Output
LOOP AT lt_items ASSIGNING FIELD-SYMBOL(<ls_item>).
WRITE: / <ls_item>-matnr, <ls_item>-stlkn, <ls_item>-idnrk,
<ls_item>-menge, <ls_item>-meins,
<ls_item>-datuv, <ls_item>-lkenz.
ENDLOOP.
" Read-only report. Does not change BOMs or change master data.Use as a starting point and verify table, field and domain names in your release with SE11 before use. This selects the BOM item records that carry the change number as the valid-from change. BOM items that end under a change number are held on a different field, so extend the query if you need both. For standard reporting, check the where-used and change number reports in CS12, CS15 and CC03 first. Test in a non-production system.
Change reporting for SAP
Optional review of which change and BOM reports your team builds by hand and how to automate them safely.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the change number, plant and BOM usage you work with, and optionally a report name. The tool produces a short report with parameters, a join of MAST to STPO, a read of the change master and a simple list output. Copy it into SE38, adjust the field list to your needs, and run it in a development or quality system first. Remember the report is read-only.
- MAST links a material and plant to a BOM number
- STPO holds the BOM items and the change number that created them
- AENR holds the change master header and its status
How the data model fits together
A material BOM is reached from the material master through MAST, which gives the BOM number STLNR, the alternative STLAL and the usage STLAN. BOM items live in STPO under the same number with the category STLTY set to M for material BOMs. Each item carries a valid-from date and change number, and the header for that change number is stored in AENR. Joining on STLTY, STLNR and AENNR is therefore enough to find the items introduced by one change.
Common mistakes
People often forget the STLTY filter, which pulls in equipment or document structure items. They also select only by date without the change number, which mixes engineering changes with direct edits, or ignore the deletion indicator. Another trap is expecting the item records to show the old state. Change history is read through the change documents and the history requirement in the BOM, so a full audit needs more than one table. Always sample a known change and compare with CS12 before trusting totals.
Frequently Asked Questions
Which tables hold the SAP engineering change number?
The change master header is stored in AENR. BOM items reference the change number in STPO, and the BOM header in STKO also carries change data. Other objects such as routings and documents reference the same number in their own tables.
Does this report change any data?
No. It only selects and writes a list. Even so, run it in a test system first and have a developer review it before it goes into production, since system load and authorization checks depend on your landscape.
Why not just use CS12 or CC03?
Standard transactions are good for single materials or single changes. A custom report helps when you need a list across many materials, an Excel export or a scheduled check. If the standard screens answer your question, use them.
Will this work on S/4HANA?
The tables are used in S/4HANA as well, but field availability and the preferred approach can change, for example with the change record and revision level concept. Verify in your release and check what simplification items affect engineering change management.
Netray builds read-only SAP reports and AI assisted queries over BOM and change data. If your team keeps requesting this kind of list, we can talk about automating it.
Related Tools
SAP BOM Where-Used SQL Generator
Fill in a component, plant and BOM usage to get SQL that lists every parent BOM using it, plus a query for BOM items with dependencies.
Engineering & PLMSAP Engineering Change Number Checklist
Walk through a change master from reason and effectivity to affected objects and release so no BOM, routing or document is changed without a number.
Engineering & PLMSAP Engineering Change Affected Materials Impact Worksheet
A row by row worksheet of affected materials with quantities, cost and disposition that totals the financial impact of a change.
Engineering & PLMEngineering Change Effectivity and Disposition Terms Reference
Searchable table of ECO and ECN vocabulary: effectivity types, stock disposition choices, change classes and related document terms, with how each shows up in an ERP.
Developer ToolsRecursive BOM Explosion SQL CTE Generator
Builds a recursive common table expression that explodes a multi-level BOM with extended quantities, plus a where-used query, using your own table and column names.
More SAP tools
See all- SAP Sales Document Types Reference
- SAP Pricing Procedure Design Worksheet
- SAP Item Category Determination Reference
- SAP Delivery Block Reasons Template
- SAP Credit Management Checklist
- SAP Output Determination Checklist
- SAP Billing Types Reference
- SAP Incompletion Log Checklist
- SAP SD Tables Reference (VBAK, VBAP, LIKP, VBRK and More)