# Mass BOM Component Replacement Upload Program

> A custom program that replaces, adds or deletes components or updates quantities in many material BOMs from Excel or CSV rows. Validity is set with a change number; in test mode it shows what will change in each BOM and how many open production orders still use the old component.

- Type: Program, Custom development, Mass upload
- Module: PP
- Estimated effort: M (5–7 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/mass-bom-component-replacement-upload-program/


## Why is the standard not enough?

CS20 mass change can replace one component in the selected BOMs, but it does not read a file; to give a different new component, quantity and validity date per line it has to be run one by one. There is no preview of the impact on open production orders before the change. CS02 changes a single BOM. Jobs with hundreds of lines, such as seasonal product changes or a supplier switch, need a templated upload with a test mode.

### Closest standard alternatives

- CS20: Replaces one component in the selected BOMs; does not read a file or show the impact on open orders.
- CS02: Changes a single BOM.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| MAST | Check of the parent material – BOM link | Read | MAST-MATNR = dosya üst malzeme AND MAST-WERKS = dosya üretim yeri | ECC + S/4 |
| STKO | BOM header; updated with the change number | Write | STKO-STLNR = MAST-STLNR AND STKO-STLAL = MAST-STLAL | ECC + S/4 |
| STPO | BOM items: component, quantity, item number | Write | STPO-STLNR = STKO-STLNR | ECC + S/4 |
| MARA | Existence, deletion flag and material status of the new component | Read | MARA-MATNR = dosya yeni bileşen | ECC + S/4 |
| RESB | Open production order requirements of the old component (impact preview) | Read | RESB-MATNR = eski bileşen AND RESB-WERKS = MAST-WERKS | ECC + S/4 |

## BAPIs and functions used

- CSAP_MAT_BOM_READ: Reads the current items on the validity date
- CSAP_MAT_BOM_MAINTAIN: Adds, deletes or replaces components or updates quantities in the BOM
- BAPI_TRANSACTION_COMMIT: Saves successful BOMs permanently
- BAPI_TRANSACTION_ROLLBACK: Rolls back the change in test mode and for failed BOMs

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Upload file (XLSX or CSV) | Single value | - | Yes |
| P_AENNR | Default change number | Single value | STPO-AENNR | No |
| P_TEST | Test mode (check without posting and show impact) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Parent material | MAST-MATNR | Yes |
| Plant | MAST-WERKS | Yes |
| BOM usage | MAST-STLAN | Yes |
| Alternative | MAST-STLAL | No |
| Action | R = replace, A = add, D = delete, Q = update quantity | Yes |
| Old component | STPO-IDNRK | No |
| New component | MARA-MATNR | No |
| Quantity | STPO-MENGE | No |
| Unit | STPO-MEINS | No |
| Item number | STPO-POSNR | No |
| Valid from | STPO-DATUV | Yes |
| Change number | STPO-AENNR | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Parent material | MAST-MATNR |
| Plant | MAST-WERKS |
| Action | Calculated: Action code from the file: R, A, D or Q |
| Old component | STPO-IDNRK |
| New component | MARA-MATNR |
| Valid from | STPO-DATUV |
| Affected open orders | Calculated: Number of production orders that carry the old component as an open requirement in RESB |
| Status | Calculated: Test passed, changed or error |
| Message | Calculated: Function return message or check error |

## How does the program work?

1. The file (XLSX or CSV) is read from the user's PC or, in a background job, from the application server; the first row is skipped as the header.
2. For every row the parent material, plant, usage and alternative are looked up in MAST and the new component in MARA; components with a deletion flag (LVORM) or a blocking material status (MSTAE) are rejected. The action must be R (replace), A (add), D (delete) or Q (quantity).
3. CSAP_MAT_BOM_READ reads the BOM items valid on the validity date; the old component to replace or delete is found together with its item number, otherwise the row fails.
4. Rows of the same BOM are grouped and passed to CSAP_MAT_BOM_MAINTAIN in one call with the change number and validity date; for a replacement the old item is sent with the deletion flag and the new component with the same item number.
5. In test mode the change is rolled back and the number of open production orders that still carry the old component as a requirement in RESB is written on the row.
6. In a real run BAPI_TRANSACTION_COMMIT is called after each successful BOM; results and messages are listed per row, and failed rows can be downloaded as a separate file.

## Authorization objects

- C_STUE_WRK: Change BOMs by plant
- C_STUE_BER: Change BOMs by BOM authorization group

## Frequently asked questions

### Are open production orders updated as well?

No. A BOM change only affects orders that are created or re-read afterwards. In test mode the program counts the affected open orders; changing the components of those orders is a separate mass order change step and can be added if required.

### Is a change number mandatory?

It is not mandatory, but recommended. With a change number the old and the new component are both kept by date and it is traceable who made the change and when. The number can be given per row in the file or as a default on the selection screen.

### Does it work on S/4HANA?

Yes. The CSAP functions are also used in S/4HANA. For a clean core approach, a move to the released BOM APIs can be evaluated separately.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=pp-bom-component-mass-change-upload
