# Mass Component Add, Delete and Change in Open Production Orders

> A program that adds, deletes and changes components in many open production orders in one go from an Excel file after an engineering or project change: quantity, storage location and project (WBS) assignment. Every line is checked in a test run first; results and error lines are returned as a file.

- Type: Program, Custom development, Mass upload
- Module: PP
- Estimated effort: M (6–10 working days)
- Last updated: 2026-11-18
- URL: https://nekuhub.com/en/programs/mass-component-add-delete-change-in-open-production-orders/


## Why is the standard not enough?

When a BOM changes, existing open orders are not updated automatically; either the order is re-read from master data (which wipes all manual changes) or each order is opened in CO02 and its components edited one by one. CS20 changes BOMs in bulk, not orders. The custom program changes only the components named in the file without re-reading the order.

### Closest standard alternatives

- CO02: Components are changed manually order by order; no mass file upload.
- CS20: Changes a component across BOMs in bulk; does not apply the change to existing production orders.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| RESB | Order components: added, deleted and changed items | Read / write | RESB-AUFNR = AFKO-AUFNR | ECC + S/4 |
| AFKO | Order header and reservation number | Read | - | ECC + S/4 |
| AFPO | Order item: material and plant | Read | AFPO-AUFNR = AFKO-AUFNR | ECC + S/4 |
| AFVC | Operation the component is assigned to | Read | AFVC-AUFPL = AFKO-AUFPL | ECC + S/4 |
| JEST | Order status: technically completed, closed, deletion flag | Read | JEST-OBJNR = AUFK-OBJNR | ECC + S/4 |
| MARC | Plant data of the component material | Read | MARC-MATNR = RESB-MATNR AND MARC-WERKS = AFPO-DWERK | ECC + S/4 |
| PRPS | WBS element check for project assignment | Read | PRPS-PSPNR = RESB-PSPEL | ECC + S/4 |

## BAPIs and functions used

- CO_XT_COMPONENT_ADD: Adds a new component to the order
- CO_XT_COMPONENT_CHANGE: Changes component quantity, storage location, operation or WBS assignment
- STATUS_READ: Checks the order status
- BAPI_TRANSACTION_COMMIT: Saves the changes per order

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Upload file (Excel) | Single value | - | Yes |
| P_WERKS | Plant | Single value | AFPO-DWERK | Yes |
| P_TEST | Test run | Checkbox | - | No |
| P_REL | Also change released orders | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Order | RESB-AUFNR | No |
| Action (A/D/C) | A = add, D = delete, C = change; R for a rule line | No |
| Operation | RESB-VORNR | No |
| Item no. | RESB-POSNR | No |
| Material | RESB-MATNR | No |
| Quantity | RESB-BDMNG | No |
| Unit | RESB-MEINS | No |
| Storage location | RESB-LGORT | No |
| WBS element | PRPS-POSID | No |

## Result list columns

| Column | Source |
|---|---|
| Order | RESB-AUFNR |
| Action | Calculated: Add, delete or change |
| Material | RESB-MATNR |
| Old value | Calculated: Quantity, storage location or WBS before the change |
| New value | Calculated: Value from the file |
| Status | Calculated: Success, test OK, warning or error |
| Message | Calculated: Function return message or check message |

## How does the program work?

1. Each file line holds one action: order, action type (A = add, D = delete, C = change), operation, item number, material, quantity, unit, storage location and an optional WBS element. Rule lines like 'replace X with Y in all open orders' are also supported; the program then finds the open orders containing the component in RESB and generates the lines itself.
2. Checks: does the order exist in AFKO/AFPO and is its status (JEST, STATUS_READ) technically completed, closed or flagged for deletion; does the operation exist in AFVC; is the material defined in the plant (MARC); is the WBS element valid in PRPS; has the component to be deleted or changed already been withdrawn (RESB-ENMNG). A withdrawn component is not deleted; the line is skipped with a warning.
3. Adding uses CO_XT_COMPONENT_ADD, changing (quantity, storage location, project assignment I_PSPEL, operation assignment) uses CO_XT_COMPONENT_CHANGE and deleting uses CO_XT_COMPONENTS_DELETE, all in the order buffer. After all lines of an order are processed, CO_XT_ORDER_PREPARE_COMMIT and BAPI_TRANSACTION_COMMIT are called; if one line fails, all changes of that order are rolled back.
4. In a test run the same steps run without commit and return a result list.
5. The result is shown per line with status and message in an ALV, failed lines can be downloaded as an error file to correct and reload, and the run is written to the application log.

## Authorization objects

- C_AFKO_AWA: Order change authorization by order type
- C_AFKO_AWK: Order authorization by plant and order type

## Frequently asked questions

### Why use this program instead of re-reading the order from master data?

Re-reading rebuilds all components and operations of the order from master data; manual changes, batch assignments and, in some cases, confirmed steps cause problems. The program touches only the components named in the file and leaves the rest of the order unchanged.

### Are the functions used official BAPIs?

No, there is no released BAPI for order components; the program calls the order buffer functions SAP uses in its own applications. That is why it commits once per order, rolls the order back on error and should be retested after upgrades. The same functions work on S/4HANA on-premise.

### What happens to a component that has already been withdrawn?

A withdrawn component is not deleted and its quantity is not reduced below the withdrawn quantity; the line is skipped with a warning. A return movement has to be posted first for such components.

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