# How to Check MRP in SAP from ABAP: MD04 Stock/Requirements List Report Generator

> Source: https://netray.co/tools/sap-ecc-md-stock-requirements-list-api-abap-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Enter material, plant or MRP controller and a horizon to get a report that prints the MD04 stock/requirements list, optionally only lines with exception messages.

## Category

developer

## Erp

SAP ECC 6.0

## Audience

- ABAP developer
- SAP PP consultant
- MRP controller
- Supply planner

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Material (used when MRP controller is blank)

**Key:** matnr

**Type:** text

**Default:** FG-100200

#### Plant

**Key:** werks

**Type:** text

**Default:** 1000

#### MRP controller (optional, lists all its materials)

**Key:** dispo

**Type:** text

#### MRP area (optional)

**Key:** berid

**Type:** text

#### Horizon (days from today)

**Key:** horizon

**Type:** number

**Default:** 90

#### Only lines with exception messages

**Key:** exceptions_only

**Type:** select

**Options:**

- N
- Y

**Default:** N

**Blocks:**

#### ABAP report: MD_STOCK_REQUIREMENTS_LIST_API

**Body:** 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 '{{werks}}',
      lv_berid TYPE berid VALUE '{{berid}}',
      lv_dispo TYPE dispo VALUE '{{dispo}}',
      lv_limit TYPE d.

START-OF-SELECTION.

  lv_limit = sy-datum + {{horizon}}.

  IF lv_dispo IS INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        input  = '{{matnr}}'
      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 '{{exceptions_only}}' = '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.

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

## Content

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

**Sections:**

#### MD04 versus MD05 and where the data comes from

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

**Bullets:**

- 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

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

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

**Bullets:**

- Exception keys are explained in the MD04 exception reference linked below.
- The stock line (DELB0 Stock) comes first with the plant stock.

#### Gotchas

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

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

**Faq:**

#### How do I check MRP results for a material in SAP?

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

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

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

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

## Search terms

how to check mrp in sap, sap mrp report, sap mrp exception report, how to run mrp in sap md04, sap mrp element table, md_stock_requirements_list_api, md04 abap report, mdez delkz delb0

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