How to Check MRP in SAP from ABAP: MD04 Stock/Requirements List Report Generator
This generator writes an ABAP report for SAP ECC 6.0 that reads the dynamic stock/requirements list, the same data MD04 shows, through MD_STOCK_REQUIREMENTS_LIST_API. It works for one material or for every material of an MRP controller, limited to a horizon and optionally to lines with exception messages.
Fill in
ABAP report: MD_STOCK_REQUIREMENTS_LIST_API
REPORT z_md04_stock_requirements.
* Reads the dynamic stock/requirements list (MD04 view) through
* MD_STOCK_REQUIREMENTS_LIST_API for one material or an MRP controller.
DATA: lt_mdpsx TYPE STANDARD TABLE OF mdps,
lt_mdezx TYPE STANDARD TABLE OF mdez,
ls_mdez TYPE mdez,
lt_mdsux TYPE STANDARD TABLE OF mdsu,
ls_mt61d TYPE mt61d,
ls_mdkp TYPE mdkp,
lt_matnr TYPE STANDARD TABLE OF matnr,
lv_matnr TYPE matnr,
lv_werks TYPE werks_d VALUE '1000',
lv_berid TYPE berid VALUE '[MRP area (optional)]',
lv_dispo TYPE dispo VALUE '[MRP controller (optional, lists all its materials)]',
lv_limit TYPE d.
START-OF-SELECTION.
lv_limit = sy-datum + 90.
IF lv_dispo IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = 'FG-100200'
IMPORTING
output = lv_matnr
EXCEPTIONS
OTHERS = 1.
APPEND lv_matnr TO lt_matnr.
ELSE.
SELECT matnr FROM marc INTO TABLE lt_matnr
WHERE werks = lv_werks
AND dispo = lv_dispo.
ENDIF.
LOOP AT lt_matnr INTO lv_matnr.
REFRESH: lt_mdpsx, lt_mdezx, lt_mdsux.
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = lv_matnr
werks = lv_werks
berid = lv_berid
IMPORTING
e_mt61d = ls_mt61d
e_mdkp = ls_mdkp
TABLES
mdpsx = lt_mdpsx
mdezx = lt_mdezx
mdsux = lt_mdsux
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE: / lv_matnr, 'not found or not planned in plant', lv_werks.
CONTINUE.
ENDIF.
SKIP.
WRITE: / 'Material', lv_matnr, 'MRP type', ls_mt61d-dismm,
'MRP controller', ls_mt61d-dispo.
WRITE: / 'Date', 12 'Elem', 18 'MRP element', 32 'Element data',
60 'Rec/Reqd qty', 80 'Available qty', 100 'Exc'.
LOOP AT lt_mdezx INTO ls_mdez.
IF ls_mdez-dat00 > lv_limit.
CONTINUE.
ENDIF.
IF 'N' = 'Y' AND ls_mdez-aussl IS INITIAL.
CONTINUE.
ENDIF.
WRITE: / ls_mdez-dat00, 12 ls_mdez-delkz, 18 ls_mdez-delb0,
32 ls_mdez-extra(26), 60 ls_mdez-mng01, 80 ls_mdez-mng02,
100 ls_mdez-aussl, ls_mdez-auskt.
ENDLOOP.
ENDLOOP.
Verify in SE37 that MD_STOCK_REQUIREMENTS_LIST_API on your release has MATNR, WERKS, BERID, E_MT61D, E_MDKP and tables MDPSX, MDEZX, MDSUX, and in SE11 that MDEZ has DAT00, DELKZ, DELB0, EXTRA, MNG01, MNG02, AUSSL and AUSKT. With MRP areas active, pass the MRP area. For hundreds of materials run it in the background: each call builds the full MD04 list.
Get a daily MRP exception digest designed
Send us your MRP controllers and exception groups and we will propose a background job and output layout that planners can act on each morning.
Optional. The tool and every export work without this. No spam.
MD04 versus MD05 and where the data comes from
MD04 is the dynamic stock/requirements list: it is built at the moment you call it from live receipts and requirements (stock, planned orders, purchase requisitions, purchase orders, production orders, sales orders, reservations, dependent requirements). MD05 is the static MRP list, a snapshot saved by the last MRP run in MDKP (header) and MDTB (items). The API returns the dynamic view, so it reflects postings since the last MRP run. MDEZX holds the lines as MD04 shows them, MDPSX the underlying item data and MDSUX the period totals.
- E_MT61D: material planning data (MRP type DISMM, controller DISPO and more).
- E_MDKP: planning file header for the material and plant.
- MDEZX: one row per MD04 line.
How to use it
Enter a material and plant to test, or leave the material and enter an MRP controller to list all its materials from MARC. The horizon cuts lines with a date after today plus N days. Set exceptions only to Y to produce a compact exception report: only lines where AUSSL (exception key) is filled. Paste into SE38, run, and compare one material with MD04. For a nightly job, schedule it in SM36 and send the spool to the planners, or replace the WRITE statements with an ALV or a file export.
Reading the output
Each line shows the date (DAT00), the MRP element type key (DELKZ), the element abbreviation as shown in MD04 (DELB0, for example PlOrd, PurRqs, POitem, PrdOrd, CusOrd, DepReq), the element data such as order number and item (EXTRA), the receipt or requirement quantity (MNG01, requirements negative) and the available quantity after this line (MNG02). AUSSL carries the exception key and AUSKT the exception number. A worked example: a CusOrd line of -40 on 2026-11-03 with MNG02 dropping to -15, followed by a PlOrd line of +50 with exception 10 (reschedule in), means the planned order arrives too late for the sales order.
- Exception keys are explained in the MD04 exception reference linked below.
- The stock line (DELB0 Stock) comes first with the plant stock.
Gotchas
If MRP areas are active, the result depends on BERID: blank reads the plant MRP area, so storage-location or subcontractor MRP areas need their own call. The API can only return materials with a planning file entry, so a material never planned raises MATERIAL_PLANT_NOT_FOUND. Quantities are in the base unit of measure. Calling the API for thousands of materials is slow because each call builds the full list; restrict by MRP controller or use the exception filter in MD06 for interactive work.
Frequently Asked Questions
How do I check MRP results for a material in SAP?
Run MD04 with material and plant for the live stock/requirements list, or MD05 for the static list saved by the last MRP run. MD06 and MD07 show lists for many materials by MRP controller with exception filters. From ABAP, MD_STOCK_REQUIREMENTS_LIST_API returns the MD04 data as internal tables.
How do I run MRP in SAP for one material and then see MD04?
Use MD03 for single-item, single-level planning, or MD02 for single-item, multi-level, then open MD04. Plant-wide total planning runs with MD01. The report generated here only reads results; it never triggers an MRP run or changes planned orders.
Which SAP table stores MRP elements?
MRP elements are not in one table; they come from their own documents (PLAF planned orders, EBAN requisitions, EKET schedule lines, RESB reservations and dependent requirements, sales schedule lines). The MRP list from the last run is saved in MDKP and MDTB. The MDEZ structure returned by the API combines them as MD04 does.
How can I create an SAP MRP exception report?
Set the exceptions-only option to Y and enter an MRP controller. The report then prints only lines with an exception key in AUSSL across that controller's materials within the horizon. MD06 offers the same interactively with exception group filters, but the report can run in the background and be mailed daily.
If your planners want to ask ECC what is short, late or needs rescheduling in plain English on your own servers, we can build that layer on top of this API.
Related Tools
SAP MD04 Exception Messages and MRP Elements Reference
A searchable lookup of MD04 element abbreviations, key exception messages and the MRP transactions you use to act on them.
SAPSAP MRP Types and MD01 Run Parameters Reference
Reference of the MRP types on the material master and the parameters you set when starting the MRP run in MD01.
SAPSAP MRP Controller Daily Worklist Template
A fill-in daily worklist for MRP controllers to record exception reviews, actions taken and open items from MD04, MD06 and MD07.
Developer ToolsSAP ECC BAPI_MATERIAL_SAVEDATA Material Creation ABAP Generator
Fill 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.
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 ABAP Stock Below Safety Stock Report GeneratorProduces a small ABAP report that joins MARC and MARD to list materials with unrestricted stock under the safety stock for a plant and MRP controller.
- 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_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.
ERP fixes and how-tos
- How to Read MD04 Exception Messages in SAPMD04 exception icons tell a planner why a procurement element no longer matches demand. Read the element detail and act on it, not just rerun MRP.
- SAP PP Standard Reports: COOIS, CO46, MD04, CM01, CS12 and PPIO_ENTRYThe standard SAP PP reports and transactions planners use: COOIS, CO46, MD04, CM01, CS12 and PPIO_ENTRY, with what each shows and when to use it.
- SAP MMBE Stock Overview: How to Run It, Read It and When to Use MB52 or MD04SAP MMBE explained: how to run the stock overview by plant, storage location and batch, what each stock column means, the tables behind it, and MB52 or MD04.
Integrations
- How to add Slack to SAP ECC 6.0Build a Slack app for SAP ECC 6.0: slash commands that read stock and orders via BAPIs, interactive approvals, alert channels and Socket Mode for on-prem.
- How to add AI agents to SAP ECC 6.0How to add AI agents to SAP ECC 6.0: a tool layer over BAPIs, RFC and IDocs, human approval before any posting, and an on-prem model that never leaves your network.