Developer ToolsFree generatorPDF, Excel, Word exportSAP ECC 6.0All SAP ECC 6.0 tools

SAP Cost Center and PM Order Actual and Planned Cost Tables: COSP/COSS Report Generator

This generator writes an ABAP report for SAP ECC 6.0 that reads CO totals for a cost center or an order (internal, maintenance or production) from COSP and COSS and prints plan, actual and variance per cost element for a period range. It shows how CO objects are keyed by OBJNR and how period value fields WKG001 to WKG016 are summed.

Fill in

KS = cost center, OR = internal, PM or production order

WKG controlling area currency, WOG object currency, WTG transaction currency

Generated code
Download:

ABAP report: COSP and COSS plan vs actual

REPORT z_co_plan_actual_cosp_coss.

* Plan vs actual per cost element for a cost center (KS) or order (OR)
* from CO totals tables COSP (primary) and COSS (secondary).
* WRTTP 01 = plan, 04 = actual. LEDNR 00 = standard CO ledger.

TYPES: BEGIN OF ty_res,
         kstar  TYPE kstar,
         plan   TYPE p LENGTH 15 DECIMALS 2,
         actual TYPE p LENGTH 15 DECIMALS 2,
       END OF ty_res.

DATA: lt_cosp  TYPE STANDARD TABLE OF cosp,
      ls_cosp  TYPE cosp,
      lt_coss  TYPE STANDARD TABLE OF coss,
      ls_coss  TYPE coss,
      lt_res   TYPE STANDARD TABLE OF ty_res,
      ls_res   TYPE ty_res,
      lv_objnr TYPE j_objnr,
      lv_kostl TYPE kostl,
      lv_aufnr TYPE aufnr,
      lv_ktopl TYPE ktopl,
      lv_ktext TYPE csku-ktext,
      lv_var   TYPE p LENGTH 15 DECIMALS 2,
      lv_tplan TYPE p LENGTH 15 DECIMALS 2,
      lv_tact  TYPE p LENGTH 15 DECIMALS 2.

START-OF-SELECTION.

* Object number: KS + controlling area + cost center (10), or OR + order (12)
  IF 'KS' = 'KS'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = '4110'
      IMPORTING
        output = lv_kostl.
    CONCATENATE 'KS' '1000' lv_kostl INTO lv_objnr.
  ELSE.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = '4110'
      IMPORTING
        output = lv_aufnr.
    CONCATENATE 'OR' lv_aufnr INTO lv_objnr.
  ENDIF.

  SELECT * FROM cosp INTO TABLE lt_cosp
    WHERE lednr = '00'
      AND objnr = lv_objnr
      AND gjahr = '2026'
      AND versn = '000'
      AND wrttp IN ('01', '04').

  SELECT * FROM coss INTO TABLE lt_coss
    WHERE lednr = '00'
      AND objnr = lv_objnr
      AND gjahr = '2026'
      AND versn = '000'
      AND wrttp IN ('01', '04').

  LOOP AT lt_cosp INTO ls_cosp.
    PERFORM add_periods USING ls_cosp.
  ENDLOOP.
  LOOP AT lt_coss INTO ls_coss.
    PERFORM add_periods USING ls_coss.
  ENDLOOP.

  SELECT SINGLE ktopl FROM tka01 INTO lv_ktopl
    WHERE kokrs = '1000'.

  SORT lt_res BY kstar.
  WRITE: / 'Object', lv_objnr, 'Year', '2026',
           'Periods 1 to 9', 'Value field WKG'.
  ULINE.
  LOOP AT lt_res INTO ls_res.
    CLEAR lv_ktext.
    SELECT SINGLE ktext FROM csku INTO lv_ktext
      WHERE spras = sy-langu
        AND ktopl = lv_ktopl
        AND kstar = ls_res-kstar.
    lv_var   = ls_res-actual - ls_res-plan.
    lv_tplan = lv_tplan + ls_res-plan.
    lv_tact  = lv_tact + ls_res-actual.
    WRITE: / ls_res-kstar, lv_ktext, ls_res-plan, ls_res-actual, lv_var.
  ENDLOOP.
  ULINE.
  lv_var = lv_tact - lv_tplan.
  WRITE: / 'Total', lv_tplan, lv_tact, lv_var.

* Sums value fields WKG001..016 for the selected periods into lt_res
FORM add_periods USING is_rec TYPE any.
  FIELD-SYMBOLS: <lv_val>   TYPE any,
                 <lv_kstar> TYPE any,
                 <lv_wrttp> TYPE any.
  DATA: lv_per   TYPE n LENGTH 3,
        lv_fname TYPE c LENGTH 30,
        ls_line  TYPE ty_res.

  ASSIGN COMPONENT 'KSTAR' OF STRUCTURE is_rec TO <lv_kstar>.
  ASSIGN COMPONENT 'WRTTP' OF STRUCTURE is_rec TO <lv_wrttp>.
  ls_line-kstar = <lv_kstar>.

  lv_per = 1.
  WHILE lv_per <= 9.
    CONCATENATE 'WKG' lv_per INTO lv_fname.
    ASSIGN COMPONENT lv_fname OF STRUCTURE is_rec TO <lv_val>.
    IF sy-subrc = 0.
      IF <lv_wrttp> = '01'.
        ls_line-plan = ls_line-plan + <lv_val>.
      ELSE.
        ls_line-actual = ls_line-actual + <lv_val>.
      ENDIF.
    ENDIF.
    lv_per = lv_per + 1.
  ENDWHILE.

  COLLECT ls_line INTO lt_res.
ENDFORM.

Check in SE11 that COSP and COSS on your release have LEDNR, OBJNR, GJAHR, WRTTP, VERSN, KSTAR and WKG001 to WKG016. ECC uses CO ledger 00; S/4HANA moves actuals to ACDOCA and keeps COSP/COSS only as compatibility views. WTG values are split by transaction currency (TWAER), so summing WTG across currencies is not meaningful. Periods 13 to 16 are special periods.

Get your CO reporting checked

Send us the cost centers, order types and versions you report on and we will confirm which value types and tables reproduce your standard reports.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

Where CO costs are stored in ECC

Controlling stores totals per object, year, value type, version and cost element. COSP holds primary costs posted from FI and MM (cost elements that are G/L accounts) and COSS holds secondary costs from allocations, settlements and activity confirmations, including partner object fields. Every object has an object number OBJNR: KS plus controlling area plus cost center for cost centers, OR plus the 12-digit order number for orders. Amounts sit in one column per period: WKG in controlling area currency, WOG in object currency, WTG in transaction currency.

  • WRTTP 01 plan, 04 actual, 21 purchase requisition commitment, 22 purchase order commitment.
  • COEP holds actual CO line items for drill-down by document.
  • PMCO holds maintenance order costs by value category.

How to use it

Choose KS and enter controlling area, cost center, year, periods and plan version 000, or choose OR and enter a maintenance or production order number (leading zeros are added). Paste the report into SE38 and run it. Each line shows cost element, text from CSKU via the chart of accounts in TKA01, plan, actual and variance (actual minus plan). For commitments, add 21 and 22 to the WRTTP list and a third column. For line items, select COEP with the same OBJNR, GJAHR and period and WRTTP 04.

  • Orders have plan values only if planned (unit costing or plan on the order).
  • Statistical postings use other value types and are not included.

Worked example

Cost center 4110 in controlling area 1000, year 2026, periods 1 to 9, version 000. Suppose COSP has cost element 476000 with WRTTP 01 and WKG001 to WKG009 of 1,000.00 each, and WRTTP 04 rows summing to 10,400.00. COSS has secondary cost element 943000 (assessment) with plan 4,500.00 and actual 4,200.00. The report prints 476000 plan 9,000.00 actual 10,400.00 variance 1,400.00, and 943000 plan 4,500.00 actual 4,200.00 variance -300.00, total variance 1,100.00. The same numbers appear in S_ALR_87013611 for the cost center and period range.

How to check in the system

For cost centers, compare with S_ALR_87013611 (cost centers: actual/plan/variance) or KSB1 for actual line items. For orders, KOB1 shows line items and the order cost analysis in IW33 or CO03 shows plan and actual by cost element. If the totals differ, check the version, the currency field you summed and whether the standard report includes statistical or commitment values. Remember that settled orders carry the settlement credit under the settlement cost element (in COSS for a secondary settlement cost element, in COSP for a primary one), so an order fully settled can show near-zero net actuals unless you exclude the settlement cost element.

Frequently Asked Questions

Which table stores actual costs of a PM order in SAP ECC?

Totals are in COSP (primary costs such as material and external services) and COSS (secondary costs such as internal activity confirmations), keyed by OBJNR OR plus the order number with WRTTP 04. Line items are in COEP. PMCO summarises maintenance order costs by value category, which the order cost overview uses.

Where are planned costs for a PM order stored?

Estimated and planned costs for maintenance orders are in COSP and COSS with WRTTP 01 and the order's OBJNR, and summarised in PMCO by value category. Planned costs come from the order's operations and components when the order is saved and costed.

Which transaction shows a cost center report in SAP?

S_ALR_87013611 shows cost centers actual/plan/variance, KSB1 shows actual line items, and KSBP plan line items. For a quick total per cost element they read the same COSP and COSS data this report queries. Report Painter reports from GR55 also run on these tables.

What is the OBJNR for a cost center in SAP?

The object number is KS followed by the four-character controlling area and the ten-character cost center, so cost center 4110 in controlling area 1000 is KS10000000004110. Orders use OR plus the 12-digit order number. Every CO totals and line item table uses OBJNR instead of separate cost center or order fields.

If controllers and maintenance planners want to ask ECC about plan versus actual costs in plain English on your own servers, we can build that layer on these CO tables.

ArchRay builder
Design the on-prem AI stack for SAP ECC 6.0: model, GPUs, RAG pipeline, guardrails
See memory, speed and cost as you swap parts, then export the diagram. Free, in your browser.
Open the builder

Keep exploring

Free tools

ERP fixes and how-tos

Runs with your ERP

AI on your ERP

Integrations