# Mass Primary Cost Reposting Upload from Excel

> A custom program that moves primary costs posted to the wrong cost center or internal order to the right object in bulk from Excel rows. It reposts in CO without touching the FI document, checks everything in test mode first and lists the CO document number of every 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-primary-cost-reposting-upload-from-excel/


## Why is the standard not enough?

KB11N enters one reposting document on a screen; it reads no file and gives no per-row check list. The dozens of corrections that come from cost center owners at month-end are therefore keyed in by hand. Reversing and re-posting in FI is usually unwanted because it affects tax and subledgers.

### Closest standard alternatives

- KB11N: Enters one reposting document on screen; no bulk posting from a file.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| COBK | Header of the resulting CO reposting document | Write | - | ECC + S/4 |
| COEP | Sender and receiver object line items | Write | - | ECC + S/4 |
| CSKS | Check that the cost center is valid and open for posting | Read | - | ECC + S/4 |
| AUFK | Existence and object number of the internal order | Read | - | ECC + S/4 |
| CSKB | Check that the cost element is primary | Read | CSKB-KOKRS = CSKS-KOKRS AND CSKB-KSTAR = COEP-KSTAR | ECC + S/4 |
| COSP | Period balance of the sending object (optional check) | Read | - | ECC + S/4 |

## BAPIs and functions used

- BAPI_ACC_PRIMARY_COSTS_POST: Reposts primary costs in CO from sender to receiver
- BAPI_TRANSACTION_COMMIT: Saves successful documents permanently

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_FILE | Upload file (XLSX or CSV) | Single value | - | Yes |
| P_KOKRS | Controlling area | Single value | COBK-KOKRS | Yes |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |
| P_BALCHK | Check the sender balance | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Document key | Rows with the same key are posted in one CO document | Yes |
| Posting date | COBK-BUDAT | Yes |
| Sending cost center | CSKS-KOSTL | No |
| Sending order | AUFK-AUFNR | No |
| Receiving cost center | CSKS-KOSTL | No |
| Receiving order | AUFK-AUFNR | No |
| Cost element | CSKB-KSTAR | Yes |
| Amount | COEP-WTGBTR | Yes |
| Currency | COEP-TWAER | Yes |
| Item text | COEP-SGTXT | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Document key | Calculated: Document key from the file |
| CO document | COBK-BELNR |
| Status | Calculated: Posted, test passed or error |
| Message | Calculated: First error or success message from the BAPI return table |

## How does the program work?

1. The file is read; rows with the same document key are collected into one CO document.
2. Every row is checked for the existence and postability of sender and receiver: the cost center must be valid in CSKS on the posting date and not locked for actual primary costs, and the internal order must exist in AUFK with a status that allows posting.
3. The cost element is confirmed as primary through CSKB-KATYP; if selected, the sender is checked for enough balance on that period and cost element to move.
4. Rows are mapped to the BAPI_ACC_PRIMARY_COSTS_POST structures: document header (controlling area, posting date, text) and sender/receiver lines. In test mode the BAPI is called as a test.
5. In a real run BAPI_TRANSACTION_COMMIT is called; the resulting CO document (COBK/COEP) and messages are listed per row.

## Authorization objects

- K_CCA: Actual posting authorization in cost center accounting
- K_ORDER: Posting authorization for internal orders

## Frequently asked questions

### Does the program change the FI document?

No. The reposting happens only in CO; the FI document, tax and subledgers are not affected. If profit center or functional area changes, the new general ledger or, on S/4HANA, the real-time integration carries it to the FI side as well.

### Can I repost into a closed period?

No. The CO period lock (OKP1) and the FI period opening settings apply. The program shows rows in a locked period as errors in test mode.

### Can the original document be referenced?

Yes. An original FI document number column can be added to the template; the program then reads the original line, checks amount and cost element, and reposts per line much like KB61.

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