# Mass Production Order Creation from File Program

> A custom program that creates production orders in bulk from material, quantity and date rows in an Excel or CSV file, and optionally releases them immediately. In test mode it checks the material, production version and order type, skips duplicate orders and lists the result of each row with the order number.

- Type: Program, Custom development, Mass upload
- Module: PP
- Estimated effort: M (4–6 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/mass-production-order-creation-from-file-program/


## Why is the standard not enough?

CO01 creates one order; CO40 and CO41 only convert planned orders created by MRP. Entering independent requirements in MD61 and running MRP is a planning process and does not give firm order quantities on specific dates. Planners who prepare the schedule outside SAP enter hundreds of rows one by one in CO01. The custom program creates the order for each row in the file through a BAPI and lists the result.

### Closest standard alternatives

- CO01: Creates one production order on screen; does not read files.
- CO41: Converts planned orders collectively; does not create orders from a list prepared outside MRP.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| MARC | Existence of the material in the plant and procurement type | Read | MARC-MATNR = dosya malzeme AND MARC-WERKS = dosya üretim yeri | ECC + S/4 |
| T399X | Order type defined for the plant | Read | T399X-WERKS = dosya üretim yeri AND T399X-AUART = dosya sipariş türü | ECC + S/4 |
| MKAL | Validity and lock of the production version | Read | MKAL-MATNR = MARC-MATNR AND MKAL-WERKS = MARC-WERKS AND MKAL-VERID = dosya versiyon | ECC + S/4 |
| AUFK | New order header (through the BAPI) | Write | AUFK-AUFNR = yeni sipariş | ECC + S/4 |
| AFKO | Order quantity and basic dates; duplicate check | Write | AFKO-AUFNR = AUFK-AUFNR | ECC + S/4 |
| AFPO | Order item: material, version, storage location | Write | AFPO-AUFNR = AUFK-AUFNR | ECC + S/4 |

## BAPIs and functions used

- BAPI_PRODORD_CREATE: Creates the production order for each valid row
- BAPI_PRODORD_RELEASE: Releases the new order when requested
- BAPI_TRANSACTION_COMMIT: Saves successful rows permanently
- BAPI_TRANSACTION_ROLLBACK: Rolls back in test mode and for failed rows

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Upload file (XLSX or CSV) | Single value | - | Yes |
| P_AUART | Default order type | Single value | AUFK-AUART | Yes |
| P_REL | Release orders immediately | Checkbox | - | No |
| P_DUPL | Skip when an open order exists for the same material and date | Checkbox | - | No |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Material | AFPO-MATNR | Yes |
| Plant | AUFK-WERKS | Yes |
| Order type (blank = default) | AUFK-AUART | No |
| Quantity | AFKO-GAMNG | Yes |
| Basic start | AFKO-GSTRP | No |
| Basic finish | AFKO-GLTRP | Yes |
| Production version | AFPO-VERID | No |
| Storage location | AFPO-LGORT | No |
| Short text | AUFK-KTEXT | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Material | AFPO-MATNR |
| Plant | AUFK-WERKS |
| Quantity | AFKO-GAMNG |
| Order | AUFK-AUFNR |
| Release | Calculated: Result of BAPI_PRODORD_RELEASE: released, not requested or error |
| Status | Calculated: Created, test passed, already exists or error |
| Message | Calculated: BAPI 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 each row MARC confirms that the material exists in the plant and is produced in-house, T399X that the order type is defined for the plant; if a production version is given, MKAL confirms it is not locked and is valid on the date.
3. With the duplicate check selected, rows for which an open order with the same material, plant and basic start date exists in AFPO/AFKO are skipped as 'already exists'.
4. For valid rows BAPI_PRODORD_CREATE is called with quantity, basic start/finish, version and storage location. In test mode the call is rolled back with BAPI_TRANSACTION_ROLLBACK.
5. With 'release immediately' selected, the new order is released with BAPI_PRODORD_RELEASE; each row is committed separately, so a failed row does not affect the others.
6. The result list shows the row, order number, release result and BAPI message; failed rows can be corrected and uploaded again with the same template.

## Authorization objects

- C_AFKO_AWA: Create and release production orders by order type
- C_AFKO_AWK: Production order authorization by plant and order type

## Frequently asked questions

### Can orders be linked to a sales order?

Yes. By adding sales order and item columns to the template, orders can be created for sales-order stock; the requirement class and account assignment are then checked as well, and the effort range increases by one or two days.

### Does creating production orders instead of planned orders disturb MRP?

No. The new production orders are seen as firm receipts in MRP; the related planned orders are reduced or deleted in the next MRP run. Keep the duplicate check on so that the same requirement is not covered by both a planned and a production order.

### Does the program work on S/4HANA?

Yes. BAPI_PRODORD_CREATE and BAPI_PRODORD_RELEASE are supported on S/4HANA. Because the production version is mandatory in S/4HANA, the program selects the valid version automatically or marks the row as failed if the version column is left blank.

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