# MD_STOCK_REQUIREMENTS_LIST_API — Read Stock/Requirements List

> Returns the stock/requirements list of a material in a plant (the data behind MD04): MRP elements, stock totals and MRP header data. It is used in custom availability, shortage and coverage reports. Call it per material and plant, read MDPSX for the elements, and handle MATERIAL_PLANT_NOT_FOUND when the material is not planned in that plant.

- Modules: PP
- Type: Function module
- Function group: M61X
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/md-stock-requirements-list-api/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| MATNR | MARC-MATNR | Material number | Yes |
| WERKS | MARC-WERKS | Plant | Yes |
| BERID | MDLV-BERID | MRP area | - |
| PLSCN | PLSC-PLSCN | Long-term planning scenario | - |
| NOBUF | CHAR1 | Do not use the buffer | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| E_MT61D | MT61D | Material MRP data |
| E_MDKP | MDKP | MRP document header |
| E_CM61M | CM61M | MRP control data at material level |
| E_MDSTA | MDSTA | Stock totals |
| E_ERGBZ | SFILT-ERGBZ | Selection rule used |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| MDPSX | MDPS | MRP elements (items) | - |
| MDEZX | MDEZ | Individual lines of the list | - |
| MDSUX | MDSU | Period totals | - |

## Exceptions

- MATERIAL_PLANT_NOT_FOUND: Material not found in the plant
- PLANT_NOT_FOUND: Plant not found

## Call template (ABAP)

```abap
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
  EXPORTING
    matnr = lv_matnr
    werks = lv_werks
  IMPORTING
    e_mt61d = lv_e_mt61d
    e_mdkp = lv_e_mdkp
    e_cm61m = lv_e_cm61m
    e_mdsta = lv_e_mdsta
    e_ergbz = lv_e_ergbz
  TABLES
    mdpsx = lt_mdpsx
    mdezx = lt_mdezx
    mdsux = lt_mdsux
  EXCEPTIONS
    material_plant_not_found = 1
    plant_not_found = 2
    OTHERS = 3.
```

## Related tables

MARC, MDKP, MDTB

