# CSAP_MAT_BOM_CREATE — Create Material BOM

> Creates a material BOM with header, items and sub-items for a material, plant and BOM usage, like CS01. It is widely used in BOM migration and in uploads from CAD or PLM systems. The API structures use character fields, so pass quantities and dates in the user's external format, and handle the ERROR exception and FL_WARNING.

- 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-create/

## 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 |
| VALID_FROM | CSAP_MBOM-DATUV | Valid-from date | - |
| CHANGE_NO | CSAP_MBOM-AENNR | Change number | - |
| REVISION_LEVEL | CSAP_MBOM-REVLV | Revision level | - |
| I_STKO | STKO_API01 | BOM header data | Yes |
| FL_COMMIT_AND_WAIT | CAPIFLAG-COMM_WAIT | Commit and wait for update | - |
| FL_NO_CHANGE_DOC | CAPIFLAG-NO_CHG_DOC | Do not write change documents | - |
| FL_DEFAULT_VALUES | CSDATA-XFELD | Use default values for new items | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| FL_WARNING | CAPIFLAG-FLWARNING | Log contains warnings |
| BOM_NO | STKO_API02-BOM_NO | BOM number |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| T_STPO | STPO_API01 | 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_CREATE'
  EXPORTING
    material = lv_material
    bom_usage = lv_bom_usage
    i_stko = lv_i_stko
  IMPORTING
    fl_warning = lv_fl_warning
    bom_no = lv_bom_no
  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

