CO Program Custom development Interface

Statistical Key Figure Actuals Upload Interface

Short answer: 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.

Estimated effort
M · 3–5 working days
System
ECC and S/4HANA
Tables
4
Scope
Global
Built by
NeKuDos Teknoloji
Last updated

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.

Who uses it? Cost accountants, controllers who want to automate the month-end close, and interface owners.

Closest standard alternatives

  • KB31N Enter Statistical Key Figures. Enters statistical key figures on screen as one document; reads no file and cannot be scheduled.
  • KB33N Display Statistical Key Figures. Displays posted key figures; does not upload.

Tables used

The tables the program reads and updates. ECC and S/4HANA differences are marked separately.

TableRoleAccessSystem
COSRCO Object: Statistical Key Figure TotalsStatistical key figure period values: read for the delta, written through the BAPIRead / writeECC + S/4
TKA03Statistical Key FiguresKey figure definition, unit and categoryReadECC + S/4
CSKSCost Center Master RecordValidity of the cost center on the posting dateReadECC + S/4
AUFKOrder Master DataExistence and object number of the receiving internal orderReadECC + S/4

BAPIs and functions used

  • BAPI_ACC_STAT_KEY_FIG_POSTAccounting: Post Statistical Key Figures. Posts statistical key figure actuals as a CO document
  • BAPI_TRANSACTION_COMMITCommit a BAPI transaction. Saves successful packages permanently
  • BAPI_TRANSACTION_ROLLBACKRoll Back BAPI Transaction. Rolls back the change in test mode and for failed packages

Selection screen parameters

ParameterDescriptionTypeReference fieldRequiredExample
P_KOKRSControlling areaSingle valueTKA03-KOKRSYes1000
P_PATHInbound folder or file pathSingle value—Yes/interface/co/skf/in/
P_BUDATPosting dateSingle valueCOBK-BUDATYes31.10.2026
P_DELTAPost only the difference for totals-type key figuresCheckbox—NoX
P_TESTTest mode (check without posting)Checkbox—NoX

Input file columns

The columns of the upload template and the SAP fields they are written to. Columns with an asterisk are mandatory.

#ColumnTarget fieldRequired
1Cost centerCSKS-KOSTLNo
2Internal order (when cost center is blank)AUFK-AUFNRNo
3Statistical key figureTKA03-STAGRYes
4ValueBy rule Period value; when P_DELTA is set, the difference to the current COSR value is postedNo
5UnitTKA03-MSEHINo
6TextCOEP-SGTXTNo

Sample upload file

1Cost centerInternal order (when cost center is blank)Statistical key figure *ValueUnitText
24110PERS15EAOctober headcount
34120PERS31EAOctober headcount
44300KWH26,900KWHOctober energy use
5600000211KWH1,250KWHTool shop project energy
A view built with fictional sample data; not real system data.

Result list columns

#ColumnSource
1RowCalculated Row number in the file
2Cost centerCSKS-KOSTL
3Internal orderAUFK-AUFNR
4Key figureTKA03-STAGR
5Posted valueCalculated File value or the difference calculated with P_DELTA
6StatusCalculated From the BAPI return messages: posted, test OK, skipped or error
7CO documentCOBK-BELNR
8MessageCalculated First error or success message from the BAPI return table

Sample result list

RowCost centerInternal orderKey figurePosted valueStatusCO documentMessage
24110PERS15Posted200015102Document posted
34120PERS31Posted200015102Document posted
44300KWH0SkippedValue already posted for the period, no difference
5600000211KWH1,250ErrorOrder is technically completed
A view built with fictional sample data; not real system data.

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.

Performance notes

One CO document can hold hundreds of lines; splitting the file into packages by key figure or cost center group makes reprocessing easier after an error. The COSR read is done in one pass with the object list.

Features

  • Test mode (check without posting)
  • Line-by-line result and error log
  • Runs as a background job Runs automatically at a set time after the file arrives in the folder.
  • Download failed lines as a separate file
  • Send the result by email Failed rows are emailed to the owner.

Authorization objects

  • K_CSKSAuthorization to post to the cost center
  • K_ORDERAuthorization to post to the internal order
  • K_CCACost 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.

Related reports

CO Program Custom Mass upload

Cost Center Cost Plan Upload from Excel

A custom program that loads periodic plan amounts per cost center and cost element from a budget file into the CO plan in bulk. It checks every row in …

COSP · CSKS · CSKB

CO Report Custom ALV report

Missing or Late Statistical Key Figures Check Report

A custom ALV report that checks, per cost center, whether the statistical key figures used as keys in assessment and distribution cycles (headcount, …

COSR · TKA03 · CSKS · CSKT

Let us build this program for your system

Briefly describe your system and expectations. We will clarify the scope and come back with an effort and price quote.

Related report: Statistical Key Figure Actuals Upload Interface