# WBS Element Cost Element Plan Upload from Excel Program

> A custom program that loads the WBS × cost element × period plan prepared by project teams in Excel into SAP in one run, tests it first and returns a result per row. During the annual planning cycle and revisions, the plan of hundreds of WBS elements is updated without manual entry.

- Type: Program, Custom development, Mass upload
- Module: PS
- Estimated effort: M (4–6 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/wbs-element-cost-plan-upload-from-excel-program/


## Why is the standard not enough?

CJR2 enters the cost element plan screen by screen per WBS element; although the planning layout supports a file transfer, the file format is rigid and it gives no pre-check and no error list per row. CJ40 only maintains the overall plan. The custom program reads a flexible Excel template, checks the WBS status and planning flag, runs the BAPI check in test mode and returns errors as a file.

### Closest standard alternatives

- CJR2: Enters the cost element plan per WBS element on screen; no flexible Excel template, pre-check or error file.
- CJ40: Maintains only the overall plan without cost elements.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| COSP | Periodic plan cost of the WBS element (WRTTP 01) | Write | - | ECC + S/4 |
| PRPS | WBS element existence, planning flag and controlling area | Read | PRPS-OBJNR = COSP-OBJNR | ECC + S/4 |
| PROJ | Project definition and closing check | Read | PROJ-PSPNR = PRPS-PSPHI | ECC + S/4 |
| JEST | Whether the WBS status allows planning | Read | JEST-OBJNR = PRPS-OBJNR | ECC + S/4 |

## BAPIs and functions used

- BAPI_COSTACTPLN_CHECKPRIMCOST: Checks the plan lines without saving in test mode
- BAPI_COSTACTPLN_POSTPRIMCOST: Writes the cost element plan into the periods for the WBS element
- BAPI_TRANSACTION_COMMIT: Saves successful plan groups 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 | PRPS-PKOKR | Yes |
| P_VERSN | Plan version | Single value | COSP-VERSN | Yes |
| P_DELTA | Delta mode (write only the difference to the existing plan) | Checkbox | - | No |
| P_TEST | Test mode (check without posting) | Checkbox | - | No |

## Input file columns

| Column | Target field | Required |
|---|---|---|
| WBS element | PRPS-POSID | Yes |
| Cost element | COSP-KSTAR | Yes |
| Fiscal year | COSP-GJAHR | Yes |
| From period | 1–12; 1 if blank | No |
| To period | 1–12; 12 if blank | No |
| Amount | Written into the COSP-WKG001…WKG012 period fields according to the distribution key | No |
| Currency | COSP-TWAER | No |
| Distribution key | 1 = equal distribution, 0 = single entry in the from period | No |

## Result list columns

| Column | Source |
|---|---|
| Row | Calculated: Row number in the file |
| WBS element | PRPS-POSID |
| Description | PRPS-POST1 |
| Cost element | COSP-KSTAR |
| Fiscal year | COSP-GJAHR |
| Amount posted | Calculated: In delta mode file amount − existing plan, otherwise file amount |
| Status | Calculated: Posted, test passed or error |
| Message | Calculated: Pre-check or BAPI return message |

## How does the program work?

1. The file is read; WBS element, cost element, fiscal year and amount are mandatory.
2. Pre-checks: the WBS element exists in PRPS, is a planning element (PLAKZ = X), belongs to the controlling area on the selection screen and its project is not closed; the cost element is valid in the selected controlling area.
3. Rows are grouped by WBS element, fiscal year and version. The amount is split into period values between the start and end period according to the distribution key (equal distribution or a single period).
4. In test mode BAPI_COSTACTPLN_CHECKPRIMCOST is called, in a real run BAPI_COSTACTPLN_POSTPRIMCOST, with the WBS element as the object. If "delta mode" is selected, the existing COSP plan values are read and only the difference is written.
5. Successful groups are saved with BAPI_TRANSACTION_COMMIT. The result of each row is shown in the ALV log; failed rows can be exported to a correction file.

## Authorization objects

- C_PROJ_KOK: Project authorization by controlling area
- C_PRPS_KOK: WBS element planning authorization by controlling area

## Frequently asked questions

### Is the existing plan overwritten or added to?

By default the amount in the file becomes the plan of the related periods. In delta mode the program reads the existing COSP plan values and saves only the difference; this avoids rewriting unchanged rows during revisions.

### Is the budget created automatically after the plan upload?

No. Plan and budget are separate values. The budget can be copied from the approved plan in CJ30, or a separate budget upload step can be added if the customer wants.

### Can it be used on S/4HANA?

Yes. BAPI_COSTACTPLN_POSTPRIMCOST is supported in S/4HANA for classic planning. If the customer has moved to the new planning solution, the same file template can be routed to its upload interface.

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