# CSAP_MAT_BOM_MAINTAIN — Maintain Material BOM

> Changes an existing material BOM and can also create it or add new items through the FL_BOM_CREATE and FL_NEW_ITEM flags, like CS02. It is used in engineering change interfaces and in mass BOM correction programs. Work with a change number when history is required, and test the item flags (FL_NEW_ITEM, FL_COMPLETE) in a test system before mass changes.

- Modules: PP
- Type: Function module
- Function group: CSAP
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/csap-mat-bom-maintain/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| MATERIAL | CSAP_MBOM-MATNR | Material number | Yes |
| PLANT | CSAP_MBOM-WERKS | Plant | - |
| BOM_USAGE | CSAP_MBOM-STLAN | BOM usage | Yes |
| ALTERNATIVE | CSAP_MBOM-STLAL | Alternative BOM | - |
| VALID_FROM | CSAP_MBOM-DATUV | Valid-from date | - |
| CHANGE_NO | CSAP_MBOM-AENNR | Change number | - |
| I_STKO | STKO_API01 | BOM header data | Yes |
| FL_BOM_CREATE | CSDATA-XFELD | Create BOM if it does not exist | - |
| FL_NEW_ITEM | CSDATA-XFELD | Create item if it does not exist | - |
| FL_COMPLETE | CSDATA-XFELD | Item list is complete | - |
| FL_COMMIT_AND_WAIT | CAPIFLAG-COMM_WAIT | Commit and wait for update | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| FL_WARNING | CAPIFLAG-FLWARNING | Log contains warnings |
| O_STKO | STKO_API02 | BOM header after the change |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| T_STPO | STPO_API03 | BOM items | - |
| T_STPU | STPU_API01 | BOM sub-items | - |
| T_LTX_LINE | CSLTX_LINE | BOM long texts | - |

## Exceptions

- ERROR: Error occurred (see log)

## Call template (ABAP)

```abap
CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
  EXPORTING
    material = lv_material
    bom_usage = lv_bom_usage
    i_stko = lv_i_stko
  IMPORTING
    fl_warning = lv_fl_warning
    o_stko = lv_o_stko
  TABLES
    t_stpo = lt_t_stpo
    t_stpu = lt_t_stpu
    t_ltx_line = lt_t_ltx_line
  EXCEPTIONS
    error = 1
    OTHERS = 2.
```

## Related tables

MAST, STAS, STKO, STPO

