# Statistical Key Figure Actuals Upload Interface

> A custom interface that reads values such as headcount, kWh or square meters delivered by HR, energy monitoring or facility systems from a file and posts them as statistical key figures to cost centers and internal orders. It runs in the background from an application server folder, with a test mode and a per-row log.

- Type: Program, Custom development, Interface
- Module: CO
- Estimated effort: M (3–5 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/statistical-key-figure-actuals-upload-interface/


## Why is the standard not enough?

KB31N enters statistical key figures on screen; it cannot read a file delivered from outside and cannot be scheduled. For hundreds of cost centers the values are keyed in or pasted from Excel every month, with a high risk of errors and gaps. For the cycles to run correctly, the values need to arrive automatically before the close.

### Closest standard alternatives

- KB31N: Enters statistical key figures on screen as one document; reads no file and cannot be scheduled.
- KB33N: Displays posted key figures; does not upload.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| COSR | Statistical key figure period values: read for the delta, written through the BAPI | Read / write | COSR-OBJNR = CSKS-OBJNR veya AUFK-OBJNR AND COSR-STAGR = dosyadaki gösterge | ECC + S/4 |
| TKA03 | Key figure definition, unit and category | Read | TKA03-KOKRS = P_KOKRS AND TKA03-STAGR = dosyadaki gösterge | ECC + S/4 |
| CSKS | Validity of the cost center on the posting date | Read | CSKS-KOKRS = P_KOKRS AND CSKS-KOSTL = dosyadaki masraf yeri | ECC + S/4 |
| AUFK | Existence and object number of the receiving internal order | Read | AUFK-AUFNR = dosyadaki sipariş AND AUFK-KOKRS = P_KOKRS | ECC + S/4 |

## BAPIs and functions used

- BAPI_ACC_STAT_KEY_FIG_POST: Posts statistical key figure actuals as a CO document
- BAPI_TRANSACTION_COMMIT: Saves successful packages permanently
- BAPI_TRANSACTION_ROLLBACK: Rolls back the change in test mode and for failed packages

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_KOKRS | Controlling area | Single value | TKA03-KOKRS | Yes |
| P_PATH | Inbound folder or file path | Single value | - | Yes |
| P_BUDAT | Posting date | Single value | COBK-BUDAT | Yes |
| P_DELTA | Post only the difference for totals-type key figures | Checkbox | - | No |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| Cost center | CSKS-KOSTL | No |
| Internal order (when cost center is blank) | AUFK-AUFNR | No |
| Statistical key figure | TKA03-STAGR | Yes |
| Value | Period value; when P_DELTA is set, the difference to the current COSR value is posted | No |
| Unit | TKA03-MSEHI | No |
| Text | COEP-SGTXT | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| Cost center | CSKS-KOSTL |
| Internal order | AUFK-AUFNR |
| Key figure | TKA03-STAGR |
| Posted value | Calculated: File value or the difference calculated with P_DELTA |
| Status | Calculated: From the BAPI return messages: posted, test OK, skipped 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 from the inbound folder on the application server (background) or from the user's PC; the processed file is moved to an archive folder.
2. Every row is checked: the key figure must exist in TKA03, the cost center must be valid in CSKS on the posting date or the internal order must exist in AUFK; the unit must match TKA03-MSEHI.
3. When P_DELTA is set, for totals-type key figures the current value of the period is read from COSR and only the difference is posted, so uploading the same file twice does not double the value.
4. Rows are packed into the BAPI_ACC_STAT_KEY_FIG_POST structure; in test mode the BAPI is called and rolled back with BAPI_TRANSACTION_ROLLBACK.
5. In a real run BAPI_TRANSACTION_COMMIT is called; the resulting CO document number, errors and skipped rows are listed in the log and can be emailed to the owner.

## Authorization objects

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

## Frequently asked questions

### What should the file format be?

Semicolon-separated CSV or XLSX can be used. If the source system sends its own code instead of the cost center, a mapping table is included in the scope.

### What happens if the same file is processed twice by mistake?

With P_DELTA on, the difference to the current value is posted, so the second upload has zero difference and the row is skipped. The processed file is moved to the archive folder.

### Can plan values be uploaded too?

This interface covers actual values. A similar upload for plan statistical key figures (KP46) can be built with a separate BAPI as additional scope.

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