# Mass Direct Activity Allocation Upload from Excel

> A custom program that reads hours and machine times spent by workshops, maintenance or service units from an Excel file and posts them as direct activity allocations from the sending cost center to a receiving cost center or internal order. It checks first, then lists the CO document number and message per row.

- Type: Program, Custom development, Mass upload
- Module: CO
- Estimated effort: M (3–5 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/mass-activity-allocation-upload-from-excel/


## Why is the standard not enough?

KB21N enters a direct activity allocation on screen as one document; it does not read a file. Hour records are often kept in a tracking tool outside SAP or in Excel, and hundreds of rows are keyed in at month end. An upload with a test mode that separates failed rows and posts the rest is needed.

### Closest standard alternatives

- KB21N: Enters a direct activity allocation on screen; does not read a file.
- KB23N: Displays posted activity allocations; does not upload.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| COEP | Activity allocation CO line items (written through the BAPI) | Write | COEP-KOKRS = P_KOKRS | ECC + S/4 |
| COSS | Secondary cost and activity quantity totals | Write | COSS-OBJNR = alıcı nesne AND COSS-PAROB = gönderen nesne | ECC + S/4 |
| CSLA | Activity type validity and unit | Read | CSLA-KOKRS = P_KOKRS AND CSLA-LSTAR = dosyadaki faaliyet türü | ECC + S/4 |
| CSKS | Validity of sending and receiving cost centers | Read | CSKS-KOKRS = P_KOKRS AND CSKS-KOSTL = dosyadaki masraf yeri | ECC + S/4 |
| AUFK | Existence of the receiving internal order | Read | AUFK-AUFNR = dosyadaki sipariş AND AUFK-KOKRS = P_KOKRS | ECC + S/4 |

## BAPIs and functions used

- BAPI_ACC_ACTIVITY_ALLOC_CHECK: Checks the package without posting
- BAPI_ACC_ACTIVITY_ALLOC_POST: Posts the direct activity allocation as a CO document
- BAPI_TRANSACTION_COMMIT: Saves successful packages permanently

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_KOKRS | Controlling area | Single value | CSLA-KOKRS | Yes |
| P_FILE | Upload file (XLSX or CSV) | Single value | - | Yes |
| P_BUDAT | Posting date | Single value | COBK-BUDAT | Yes |
| P_BLTXT | Document header text | Single value | COBK-BLTXT | No |
| P_PACK | Lines per document | Single value | - | No |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Sending cost center | CSKS-KOSTL | Yes |
| Activity type | CSLA-LSTAR | Yes |
| Receiving cost center | CSKS-KOSTL | No |
| Receiving internal order | AUFK-AUFNR | No |
| Quantity | COEP-MBGBTR | Yes |
| Unit | CSLA-LEINH | No |
| Text | COEP-SGTXT | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Sending cost center | CSKS-KOSTL |
| Activity type | CSLA-LSTAR |
| Receiver | Calculated: Receiving cost center or internal order number |
| Quantity | COEP-MBGBTR |
| Status | Calculated: From the BAPI return messages: posted, test OK or error |
| CO document | COBK-BELNR |
| Message | Calculated: First error or success message from the BAPI return table |

## How does the program work?

1. The file is read; sending cost center, activity type, receiver (cost center or internal order) and quantity are mandatory on every row.
2. Checks: the sending and receiving cost centers must be valid in CSKS on the posting date, the internal order must exist in AUFK, the activity type must be valid in CSLA and the unit in the file must match CSLA-LEINH.
3. Rows are split into packages of P_PACK lines and checked with BAPI_ACC_ACTIVITY_ALLOC_CHECK; failed packages are resolved row by row.
4. In test mode only the check result is shown. In a real run BAPI_ACC_ACTIVITY_ALLOC_POST is called and then saved with BAPI_TRANSACTION_COMMIT.
5. The posted value is calculated with the planned activity price and written to COEP/COSS; the CO document number, errors and a file of failed rows are listed.

## Authorization objects

- K_CSKS: Authorization to post to sending and receiving cost centers
- K_ORDER: Authorization to post to the receiving internal order
- K_CCA: Cost center accounting transaction authorization

## Frequently asked questions

### How is the allocated amount calculated?

The quantity is multiplied by the planned price of the activity type on the sending cost center. Without a plan price the row fails; prices are planned in KP26.

### Can an incorrect upload be reversed?

Yes, the resulting CO document is reversed with KB24N. Because the program lists the document number, the reversal is easy.

### Can activities be allocated to production orders too?

Activities usually reach production orders through confirmations. This program covers cost centers and internal orders; other receiver types are assessed as additional scope.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=co-activity-allocation-upload
