# MATERIAL_MAINTAIN_DARK — Maintain Material Master in Background

> Creates or changes material master data without screens (in the background); the data is passed in transfer tables such as MARA_UEB, MARC_UEB and MBEW_UEB, with a transaction number (TRANC) in each row. It is used in older developments that must load fields not covered by the material master BAPIs and in some SAP-internal transfer processes. It is not a released interface: prefer BAPI_MATERIAL_SAVEDATA or BAPI_MATERIAL_SAVEREPLICA in new developments, and read the errors from the AMERRDAT table.

- Modules: MM
- Type: Function module
- Function group: MGMD
- Remote-enabled (RFC): No
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/material-maintain-dark/

## ABAP Cloud and clean core status

Not to be released for ABAP Cloud (LO-MD-MM). SAP does not release this object for ABAP Cloud. It keeps working in classic ABAP; in ABAP Cloud and clean core development use the successor below.

- Use instead in ABAP Cloud: I_PRODUCTTP_2

Source: SAP's list of released objects (S/4HANA Cloud Private Edition, latest), SAP Cloudification Repository (https://github.com/SAP/abap-atc-cr-cv-s4hc)

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| KZ_PRF | RMMG08_012-MSGTYP | Check level (message type) | Yes |
| P_KZ_NO_WARN | RMMG08_012-MSGTYP | Suppress warnings | Yes |
| CALL_MODE | MMDCMODE-CALL_MODE | Call mode | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| MATNR_LAST | MARA-MATNR | Last material processed |
| NUMBER_ERRORS_TRANSACTION | TBIST-NUMERROR | Number of erroneous transactions |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| AMARA_UEB | MARA_UEB | General material data | Yes |
| AMAKT_UEB | MAKT_UEB | Material descriptions | - |
| AMARC_UEB | MARC_UEB | Plant data | - |
| AMARD_UEB | MARD_UEB | Storage location data | - |
| AMARM_UEB | MARM_UEB | Units of measure | - |
| AMBEW_UEB | MBEW_UEB | Valuation data | - |
| AMVKE_UEB | MVKE_UEB | Sales data | - |
| AMFIELDRES | MFIELDRES | Fields to be reset | - |
| AMERRDAT | MERRDAT | Error messages | - |

## Exceptions

- KSTATUS_EMPTY: Maintenance status empty
- TKSTATUS_EMPTY: View status empty
- T130M_ERROR: Transaction control table error
- INTERNAL_ERROR: Internal error
- TOO_MANY_ERRORS: Too many errors
- UPDATE_ERROR: Update error
- ERROR_PROPAGATE_HEADER: Error propagated to header

## Call template (ABAP)

```abap
CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
  EXPORTING
    kz_prf = lv_kz_prf
    p_kz_no_warn = lv_p_kz_no_warn
  IMPORTING
    matnr_last = lv_matnr_last
    number_errors_transaction = lv_number_errors_transaction
  TABLES
    amara_ueb = lt_amara_ueb
    amakt_ueb = lt_amakt_ueb
    amarc_ueb = lt_amarc_ueb
    amard_ueb = lt_amard_ueb
    amarm_ueb = lt_amarm_ueb
    ambew_ueb = lt_ambew_ueb
    amvke_ueb = lt_amvke_ueb
    amfieldres = lt_amfieldres
    amerrdat = lt_amerrdat
  EXCEPTIONS
    kstatus_empty = 1
    tkstatus_empty = 2
    t130m_error = 3
    internal_error = 4
    too_many_errors = 5
    update_error = 6
    error_propagate_header = 7
    OTHERS = 8.
```

## Related tables

MAKT, MARA, MARC, MBEW, MVKE

