# Mass Purchase Order Creation from Excel Program

> A custom program that creates purchase orders in bulk from Excel or CSV rows, grouping them by vendor, purchasing organization and group number. It checks all rows in test mode first, then lists the number created for each order and the messages per row.

- Type: Program, Custom development, Mass upload
- Module: MM
- Estimated effort: M (5–7 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/mass-purchase-order-creation-from-excel-program/


## Why is the standard not enough?

ME21N creates each order one at a time on screen. ME59N only converts existing purchase requisitions; it does not cover bulk orders placed without a requisition. LSMW recordings are fragile on the ME21N Enjoy screens. Project purchases with hundreds of items or periodic price-list orders need a templated upload with a test mode.

### Closest standard alternatives

- ME21N: Creates orders one at a time on screen; does not read a file.
- ME59N: Converts existing requisitions into orders automatically; does not create bulk orders without requisitions.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| EKKO | Order header: vendor, organization, document type | Write | - | ECC + S/4 |
| EKPO | Order item: material, plant, quantity, price | Write | - | ECC + S/4 |
| EKET | Schedule line and delivery date | Write | - | ECC + S/4 |
| EKKN | Account assignment: cost center or WBS element | Write | - | ECC + S/4 |
| LFM1 | Vendor purchasing organization data and block (check) | Read | LFM1-LIFNR = EKKO-LIFNR AND LFM1-EKORG = EKKO-EKORG | ECC + S/4 |
| MARC | Material exists in the plant (check) | Read | MARC-MATNR = EKPO-MATNR AND MARC-WERKS = EKPO-WERKS | ECC + S/4 |
| EINE | Info record net price when the price is blank | Read | EINE-EKORG = EKKO-EKORG AND EINE-WERKS = EKPO-WERKS | ECC + S/4 |

## BAPIs and functions used

- BAPI_PO_CREATE1: Creates each order group as one purchase order; only checks in test mode
- BAPI_TRANSACTION_COMMIT: Saves a successful order permanently
- BAPI_TRANSACTION_ROLLBACK: Rolls back the changes of a failed order
- TEXT_CONVERT_XLS_TO_SAP: Reads the Excel file into an internal table

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Upload file (XLSX or CSV) | Single value | - | Yes |
| P_BSART | Order document type | Single value | EKKO-BSART | Yes |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |
| P_INFO | Take price from info record if blank | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Group no (same number = same order) | Grouping key in the file; together with vendor and organization it defines the order header | Yes |
| Vendor | EKKO-LIFNR | Yes |
| Purchasing organization | EKKO-EKORG | Yes |
| Purchasing group | EKKO-EKGRP | Yes |
| Company code | EKKO-BUKRS | Yes |
| Material (blank for text items) | EKPO-MATNR | No |
| Short text | EKPO-TXZ01 | No |
| Plant | EKPO-WERKS | Yes |
| Quantity | EKPO-MENGE | Yes |
| Unit | EKPO-MEINS | No |
| Net price (blank = info record) | EKPO-NETPR | No |
| Delivery date | EKET-EINDT | Yes |
| Account assignment category | EKPO-KNTTP | No |
| Cost center | EKKN-KOSTL | No |
| WBS element | EKKN-PS_PSP_PNR | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Group no | Calculated: Group number from the file |
| Vendor | EKKO-LIFNR |
| Purchase order | EKKO-EBELN |
| Item | EKPO-EBELP |
| Net value | EKPO-NETWR |
| Status | Calculated: From the BAPI return messages: checked, created or error |
| Message | Calculated: First error or success message from the BAPI return table |

## How does the program work?

1. The file is read from the user's PC (TEXT_CONVERT_XLS_TO_SAP) or, in a background job, from the application server; rows are split into order headers by group number, vendor, purchasing organization, purchasing group and company code.
2. Every row is checked: the vendor's purchasing organization data (LFM1) and blocks, the material existing in the plant (MARC), the unit of measure, the delivery date and the account assignment. If the price is blank, it is taken from the valid purchasing info record (EINE).
3. Rows are mapped to the BAPI_PO_CREATE1 structures: POHEADER, POITEM, POSCHEDULE and, for account-assigned items, POACCOUNT (cost center or WBS element).
4. In test mode the BAPI is called with TESTRUN = X, so all errors and warnings are visible without a number being assigned.
5. In a real run BAPI_TRANSACTION_COMMIT is called after each successful order and BAPI_TRANSACTION_ROLLBACK after a failed one; the result list shows the order number and row messages, and failed rows can be downloaded as a separate file.

## Authorization objects

- M_BEST_BSA: Purchase order create authorization by document type
- M_BEST_EKO: Purchase order create authorization by purchasing organization
- M_BEST_EKG: Purchase order create authorization by purchasing group
- M_BEST_WRK: Purchase order create authorization by plant

## Frequently asked questions

### Do the created orders go through the release strategy?

Yes. BAPI_PO_CREATE1 creates the order with the standard rules; if the order type and value match a release strategy, the order waits for release.

### Can conditions (discounts, freight) be loaded too?

They can be loaded through the POCOND structure by adding condition type and amount columns to the template. Each extra field group increases the effort range.

### Can this program be used on S/4HANA?

Yes. BAPI_PO_CREATE1 is supported on S/4HANA. For a clean core approach, the same file logic can also be built on the purchase order API.

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