Cost centers by controlling area with every CSKS/CSKT column: HANA SQL in DB02/ST04 (S/4HANA and ECC versions)

Give it a controlling area (KOKRS) and it returns every cost center underneath with all CSKS columns, plus the names from CSKT. Plain HANA SQL for DB02/ST04 → Diagnostics → SQL Editor; an S/4HANA version and an ECC version are both included.

Verified on an S/4HANA sandbox: controlling area JNC2 (JNC #2 Controlling Area), client 100. Written 2026-08-31.

1. Result — 5 cost centers in JNC2

CaseCost centers under controlling area JNC2 (output of the query in section 6)
What it doesThe five cost centers of JNC2 with the CSKT name, category, functional area and standard hierarchy node. The full query returns all 84 CSKS columns; the grid below shows the columns that carry the meaning.
Result5 rows
Result — 5 rows (KOKRS = JNC2)
KOSTL    | KTEXT (CSKT)           | KOSAR | FUNC_AREA            | KHINR (std hierarchy node)
---------+------------------------+-------+----------------------+---------------------------
JNC21010 | SG&A                   | 2     | JNCS (SG&A)          | JNC210 (SG&A)
JNC27010 | Subcontract            | 1     | JNCM (Manufacturing) | JNC22030 (Subcontract)
JNC28010 | Indirect Manufacturing | 3     | JNCM (Manufacturing) | JNC22010 (Indirect Manuf.)
JNC29010 | Direct Manufacturing   | 1     | JNCM (Manufacturing) | JNC22020 (DIrect Manuf.)
JNC29020 | Direct Manufacturing   | 1     | JNCM (Manufacturing) | JNC22020 (DIrect Manuf.)

2. One record in full — JNC21010 (every column that holds a value)

CaseAll populated columns of cost center JNC21010
What it doesOne row of the section 6 result, turned sideways. Columns that are blank on this system (address, telephone, JVA, templates and so on) are left out; section 4 lists them.
Watch outKTEXT / LTEXT / MCTXT are not CSKS columns — they come from the CSKT join.
Result24 populated columns
Result — JNC21010, 24 populated columns
FIELD     | VALUE            | MEANING                        | WHAT THE CODE POINTS TO
----------+------------------+--------------------------------+---------------------------------------------------
MANDT     | 100              | Client                         |
KOKRS     | JNC2             | Controlling area               | JNC #2 Controlling Area (TKA01)
KOSTL     | JNC21010         | Cost center                    |
KTEXT     | SG&A             | General name                   | from the CSKT join
LTEXT     | SG&A             | Description (long name)        | from the CSKT join
MCTXT     | SG&A             | Search term (upper case)       | from the CSKT join
DATAB     | 2026.01.01       | Valid from                     |
DATBI     | 9999.12.31       | Valid to                       | key field — change history stacks up as extra rows
BUKRS     | JNC2             | Company code                   | JNC #2 Company Code (T001, Seoul/KRW)
GSBER     | JNC2             | Business area                  | JNC #2 Business Area (TGSBT)
KOSAR     | 2                | Cost center category           | defined in OKA2 (TKA05)
VERAK     | Person Responsib | Person responsible             | free text, not a master-data reference
WAERS     | KRW              | Currency key                   | South Korean Won (TCURT)
PRCTR     | JNC2             | Profit center                  | JNC #2 Prof. Center (CEPCT)
KHINR     | JNC210           | Standard hierarchy area        | SG&A (SETHEADERT, set class 0101)
FUNC_AREA | JNCS             | Functional area                | SG&A (TFKBT)
OBJNR     | KSJNC2JNC21010   | Object number                  | KS + KOKRS + KOSTL
ERSDA     | 2026.07.24       | Created on                     |
USNAM     | HUB2146          | Created by                     |
BKZER     | X                | Lock: actual revenue postings  |
BKZOB     | X                | Lock: commitment update        |
PKZER     | X                | Lock: plan revenues            |
MGEFL     | X                | Records consumption quantities |
KOMPL     | X                | Master record complete         |

3. Column dictionary — key, organizational assignment, history, locks

GroupFieldMeaning
KeyMANDTClient
KeyKOKRSControlling area
KeyKOSTLCost center
KeyDATBIValid to — part of the key, so one cost center can have several rows
PeriodDATABValid from
Org. assignmentBUKRSCompany code
Org. assignmentGSBERBusiness area
Org. assignmentKOSARCost center category
Org. assignmentPRCTRProfit center
Org. assignmentWERKSPlant
Org. assignmentFUNC_AREAFunctional area
Org. assignmentKHINRStandard hierarchy area — a node of the cost center group tree
Org. assignmentABTEIDepartment
Org. assignmentWAERSCurrency key
Org. assignmentLAND1Country/region key
Org. assignmentLOGSYSTEMLogical system
Org. assignmentOBJNRObject number — the join key to CO line items (COEP and others)
Responsible / historyVERAKPerson responsible (free text)
Responsible / historyVERAK_USERUser responsible (SAP user ID)
Responsible / historyERSDACreated on
Responsible / historyUSNAMCreated by
LockBKZKPLock: actual primary postings
LockPKZKPLock: plan primary costs
LockBKZKSLock: actual secondary costs
LockPKZKSLock: plan secondary costs
LockBKZERLock: actual revenue postings
LockPKZERLock: plan revenues
LockBKZOBLock: commitment update (purchase requisitions / purchase orders)

4. Column dictionary — control, templates, industry add-ons, texts

GroupFieldMeaning
Control / calculationVMETHIndicator for allowed allocation methods
Control / calculationMGEFLRecords consumption quantities
Control / calculationKALSMCosting sheet (overhead calculation)
Control / calculationKOSZSCHLCO-CCA overhead key
Control / calculationKVEWEUsage of the condition table
Control / calculationKAPPLApplication
Control / calculationTXJCDTax jurisdiction
Control / calculationSTAKZStatistical object indicator
Control / calculationKOMPLMaster record complete
Control / calculationNKOSTSubsequent cost center (follow-on assignment)
Control / calculationCCKEYCost collector key
Control / calculationDRNAMPrinter name for cost center reports
Control / calculationFUNKTCost center function
Control / calculationAFUNKAlternative cost center function
TemplateCPI_TEMPLTemplate: activity-independent formula planning
TemplateCPD_TEMPLTemplate: activity-dependent formula planning
TemplateSCI_TEMPLTemplate: activity-independent allocation
TemplateSCD_TEMPLTemplate: activity-dependent allocation
TemplateSKI_TEMPLTemplate: statistical key figures, activity-independent
TemplateSKD_TEMPLTemplate: statistical key figures, activity-dependent
Address / contactANRED / NAME1~4 / ORT01~02 / STRAS / PFACH / PSTLZ / PSTL2 / REGIO / SPRAS14 address fields — all blank on this system
Address / contactTELBX / TELF1~2 / TELFX / TELTX / TELX1 / DATLT7 telephone / fax / telecom fields — all blank
JVAVNAMEJoint venture
JVARECIDRecovery indicator
JVAETYPEEquity type
JVAJV_OTYPEJoint venture object type
JVAJV_JIBCLJIB/JIBE class
JVAJV_JIBSAJIB/JIBE subclass A
OtherFERC_INDRegulatory reporting indicator
PSMFUNDFund — usually absent in ECC
PSMGRANT_IDGrant — named GRANT_NBR in ECC
PSMFUND_FIX_ASSIGNEDFund fixed assignment — usually absent in ECC
PSMGRANT_FIX_ASSIGNEDGrant fixed assignment — usually absent in ECC
PSMFUNC_AREA_FIX_ASSIGNEDFunctional area fixed assignment — usually absent in ECC
S/4HANA onlyBUDGET_CARRYING_COST_CTRBudget-carrying cost center
S/4HANA onlyAVC_PROFILEAvailability control profile
S/4HANA onlyAVC_ACTIVEAvailability control active
S/4HANA onlyEEW_CSKS_PS_DUMMYExtension field dummy
Text (CSKT)KTEXTGeneral name, 20 characters — lives in CSKT, not CSKS
Text (CSKT)LTEXTDescription (long name), 40 characters
Text (CSKT)MCTXTSearch term, upper case

5. Putting a name next to each code — text table mapping

Code fieldText tableJoin keyText field
KOKRSTKA01MANDT + KOKRSBEZEI
KOSTLCSKTMANDT + KOKRS + KOSTL + DATBI + SPRASKTEXT / LTEXT / MCTXT
BUKRST001MANDT + BUKRSBUTXT
GSBERTGSBTMANDT + GSBER + SPRASGTEXT
PRCTRCEPCTMANDT + KOKRS + PRCTR + DATBI + SPRASKTEXT / LTEXT
WERKST001WMANDT + WERKSNAME1
FUNC_AREATFKBTMANDT + FKBER + SPRASFKBTX
KHINRSETHEADERTMANDT + SETCLASS('0101') + SUBCLASS(=KOKRS) + SETNAME + LANGUDESCRIPT
WAERSTCURTMANDT + WAERS + SPRASLTEXT / KTEXT
LAND1T005TMANDT + LAND1 + SPRASLANDX
KOSAR(none)TKA05 has no text column and the domain has no fixed valuesvisible only in the OKA2 screen

6. S/4HANA — the query for DB02/ST04

CaseAll 84 CSKS columns + 12 names next to the codes (10 text tables joined)
What it doesA code value alone tells you little, so every code field that has a text table gets its name in the next column through a LEFT JOIN (aliases like KOKRS_TXT, BUKRS_TXT). The remaining columns without a text follow underneath, five per line.
Watch outThe HANA SQL editor does not filter by client. MANDT has to be in the WHERE clause and in every join condition.
Watch outText tables multiply rows by the number of languages unless SPRAS/LANGU is restricted. For Korean names replace 'E' with '3' — the SAP language code for Korean is '3', not 'K'.
Watch outCSKT has the validity period in its key, so it is joined on k.DATBI. CEPCT is pinned to the currently valid entry with DATBI = '99991231'.
Result5 rows for JNC2 — see section 1
SELECT
    k.MANDT,
    k.KOKRS,        ka.BEZEI     AS KOKRS_TXT,
    k.KOSTL,        t.KTEXT      AS KOSTL_TXT,
    t.LTEXT         AS KOSTL_LTXT,
    t.MCTXT         AS KOSTL_MCTXT,
    k.DATAB,        k.DATBI,
    k.BUKRS,        bu.BUTXT     AS BUKRS_TXT,
    k.GSBER,        gs.GTEXT     AS GSBER_TXT,
    k.PRCTR,        pc.KTEXT     AS PRCTR_TXT,
    k.WERKS,        wk.NAME1     AS WERKS_TXT,
    k.FUNC_AREA,    fa.FKBTX     AS FUNC_AREA_TXT,
    k.KHINR,        sh.DESCRIPT  AS KHINR_TXT,
    k.WAERS,        cu.LTEXT     AS WAERS_TXT,
    k.LAND1,        ct.LANDX     AS LAND1_TXT,

    k.KOSAR,        k.VERAK,        k.VERAK_USER,   k.ABTEI,        k.NKOST,
    k.ERSDA,        k.USNAM,        k.LOGSYSTEM,    k.OBJNR,        k.KOMPL,
    k.BKZKP,        k.PKZKP,        k.BKZKS,        k.PKZKS,        k.BKZER,
    k.PKZER,        k.BKZOB,        k.VMETH,        k.MGEFL,        k.KALSM,
    k.KOSZSCHL,     k.KVEWE,        k.KAPPL,        k.TXJCD,        k.STAKZ,
    k.CCKEY,        k.DRNAM,        k.FUNKT,        k.AFUNK,        k.CPI_TEMPL,
    k.CPD_TEMPL,    k.SCI_TEMPL,    k.SCD_TEMPL,    k.SKI_TEMPL,    k.SKD_TEMPL,
    k.ANRED,        k.NAME1,        k.NAME2,        k.NAME3,        k.NAME4,
    k.ORT01,        k.ORT02,        k.STRAS,        k.PFACH,        k.PSTLZ,
    k.PSTL2,        k.REGIO,        k.SPRAS,        k.TELBX,        k.TELF1,
    k.TELF2,        k.TELFX,        k.TELTX,        k.TELX1,        k.DATLT,
    k.VNAME,        k.RECID,        k.ETYPE,        k.JV_OTYPE,     k.JV_JIBCL,
    k.JV_JIBSA,     k.FERC_IND,
    k.EEW_CSKS_PS_DUMMY,            k.BUDGET_CARRYING_COST_CTR,
    k.AVC_PROFILE,  k.AVC_ACTIVE,   k.FUND,         k.GRANT_ID,
    k.FUND_FIX_ASSIGNED,            k.GRANT_FIX_ASSIGNED,
    k.FUNC_AREA_FIX_ASSIGNED
FROM      CSKS k
LEFT JOIN CSKT       t  ON t.MANDT  = k.MANDT
                       AND t.KOKRS  = k.KOKRS
                       AND t.KOSTL  = k.KOSTL
                       AND t.DATBI  = k.DATBI
                       AND t.SPRAS  = 'E'
LEFT JOIN TKA01      ka ON ka.MANDT = k.MANDT
                       AND ka.KOKRS = k.KOKRS
LEFT JOIN T001       bu ON bu.MANDT = k.MANDT
                       AND bu.BUKRS = k.BUKRS
LEFT JOIN TGSBT      gs ON gs.MANDT = k.MANDT
                       AND gs.GSBER = k.GSBER
                       AND gs.SPRAS = 'E'
LEFT JOIN CEPCT      pc ON pc.MANDT = k.MANDT
                       AND pc.KOKRS = k.KOKRS
                       AND pc.PRCTR = k.PRCTR
                       AND pc.DATBI = '99991231'
                       AND pc.SPRAS = 'E'
LEFT JOIN T001W      wk ON wk.MANDT = k.MANDT
                       AND wk.WERKS = k.WERKS
LEFT JOIN TFKBT      fa ON fa.MANDT = k.MANDT
                       AND fa.FKBER = k.FUNC_AREA
                       AND fa.SPRAS = 'E'
LEFT JOIN SETHEADERT sh ON sh.MANDT    = k.MANDT
                       AND sh.SETCLASS = '0101'
                       AND sh.SUBCLASS = k.KOKRS
                       AND sh.SETNAME  = k.KHINR
                       AND sh.LANGU    = 'E'
LEFT JOIN TCURT      cu ON cu.MANDT = k.MANDT
                       AND cu.WAERS = k.WAERS
                       AND cu.SPRAS = 'E'
LEFT JOIN T005T      ct ON ct.MANDT = k.MANDT
                       AND ct.LAND1 = k.LAND1
                       AND ct.SPRAS = 'E'
WHERE k.MANDT = '100'
  AND k.KOKRS = 'JNC2'
ORDER BY k.KOSTL, k.DATBI DESC;

7. ECC — the query for DB02/ST04

CaseThe same query without the 9 columns that do not exist in ECC (75 CSKS columns + 12 names)
What it doesCSKS/CSKT and the 10 text tables have almost the same structure in ECC and S/4HANA, so the join syntax carries over unchanged. Pasting the S/4HANA query into ECC fails with column-not-found, because 9 columns exist only in S/4HANA or with an add-on: EEW_CSKS_PS_DUMMY, BUDGET_CARRYING_COST_CTR, AVC_PROFILE, AVC_ACTIVE, FUND, GRANT_ID, FUND_FIX_ASSIGNED, GRANT_FIX_ASSIGNED, FUNC_AREA_FIX_ASSIGNED. This version drops those 9.
Watch outIf it still fails, remove the 6 JVA (joint venture) columns VNAME / RECID / ETYPE / JV_OTYPE / JV_JIBCL / JV_JIBSA and FERC_IND and run again — these are industry add-on columns and may be missing depending on the system.
ResultNo result set recorded in the source (the query differs from the S/4HANA version only by the dropped columns).
SELECT
    k.MANDT,
    k.KOKRS,        ka.BEZEI     AS KOKRS_TXT,
    k.KOSTL,        t.KTEXT      AS KOSTL_TXT,
    t.LTEXT         AS KOSTL_LTXT,
    t.MCTXT         AS KOSTL_MCTXT,
    k.DATAB,        k.DATBI,
    k.BUKRS,        bu.BUTXT     AS BUKRS_TXT,
    k.GSBER,        gs.GTEXT     AS GSBER_TXT,
    k.PRCTR,        pc.KTEXT     AS PRCTR_TXT,
    k.WERKS,        wk.NAME1     AS WERKS_TXT,
    k.FUNC_AREA,    fa.FKBTX     AS FUNC_AREA_TXT,
    k.KHINR,        sh.DESCRIPT  AS KHINR_TXT,
    k.WAERS,        cu.LTEXT     AS WAERS_TXT,
    k.LAND1,        ct.LANDX     AS LAND1_TXT,

    k.KOSAR,        k.VERAK,        k.VERAK_USER,   k.ABTEI,        k.NKOST,
    k.ERSDA,        k.USNAM,        k.LOGSYSTEM,    k.OBJNR,        k.KOMPL,
    k.BKZKP,        k.PKZKP,        k.BKZKS,        k.PKZKS,        k.BKZER,
    k.PKZER,        k.BKZOB,        k.VMETH,        k.MGEFL,        k.KALSM,
    k.KOSZSCHL,     k.KVEWE,        k.KAPPL,        k.TXJCD,        k.STAKZ,
    k.CCKEY,        k.DRNAM,        k.FUNKT,        k.AFUNK,        k.CPI_TEMPL,
    k.CPD_TEMPL,    k.SCI_TEMPL,    k.SCD_TEMPL,    k.SKI_TEMPL,    k.SKD_TEMPL,
    k.ANRED,        k.NAME1,        k.NAME2,        k.NAME3,        k.NAME4,
    k.ORT01,        k.ORT02,        k.STRAS,        k.PFACH,        k.PSTLZ,
    k.PSTL2,        k.REGIO,        k.SPRAS,        k.TELBX,        k.TELF1,
    k.TELF2,        k.TELFX,        k.TELTX,        k.TELX1,        k.DATLT,
    k.VNAME,        k.RECID,        k.ETYPE,        k.JV_OTYPE,     k.JV_JIBCL,
    k.JV_JIBSA,     k.FERC_IND
FROM      CSKS k
LEFT JOIN CSKT       t  ON t.MANDT  = k.MANDT
                       AND t.KOKRS  = k.KOKRS
                       AND t.KOSTL  = k.KOSTL
                       AND t.DATBI  = k.DATBI
                       AND t.SPRAS  = 'E'
LEFT JOIN TKA01      ka ON ka.MANDT = k.MANDT
                       AND ka.KOKRS = k.KOKRS
LEFT JOIN T001       bu ON bu.MANDT = k.MANDT
                       AND bu.BUKRS = k.BUKRS
LEFT JOIN TGSBT      gs ON gs.MANDT = k.MANDT
                       AND gs.GSBER = k.GSBER
                       AND gs.SPRAS = 'E'
LEFT JOIN CEPCT      pc ON pc.MANDT = k.MANDT
                       AND pc.KOKRS = k.KOKRS
                       AND pc.PRCTR = k.PRCTR
                       AND pc.DATBI = '99991231'
                       AND pc.SPRAS = 'E'
LEFT JOIN T001W      wk ON wk.MANDT = k.MANDT
                       AND wk.WERKS = k.WERKS
LEFT JOIN TFKBT      fa ON fa.MANDT = k.MANDT
                       AND fa.FKBER = k.FUNC_AREA
                       AND fa.SPRAS = 'E'
LEFT JOIN SETHEADERT sh ON sh.MANDT    = k.MANDT
                       AND sh.SETCLASS = '0101'
                       AND sh.SUBCLASS = k.KOKRS
                       AND sh.SETNAME  = k.KHINR
                       AND sh.LANGU    = 'E'
LEFT JOIN TCURT      cu ON cu.MANDT = k.MANDT
                       AND cu.WAERS = k.WAERS
                       AND cu.SPRAS = 'E'
LEFT JOIN T005T      ct ON ct.MANDT = k.MANDT
                       AND ct.LAND1 = k.LAND1
                       AND ct.SPRAS = 'E'
WHERE k.MANDT = '100'
  AND k.KOKRS = 'JNC2'
ORDER BY k.KOSTL, k.DATBI DESC;
CaseStill failing — list the real columns of CSKS on your system first
What it doesIf either query reports a missing column, read the actual column list of CSKS from the dictionary (DD03L). Copy the FIELDNAME values into the SELECT list and the query will run. POSITION is the physical column order.
Watch outDD03L is client-independent — there is no MANDT column, so a MANDT condition added out of habit causes an error.
Watch outAS4LOCAL = 'A' restricts to the active version; FIELDNAME NOT LIKE '.%' removes the .INCLUDE rows that are not real columns.
ResultOne row per CSKS column, in POSITION order
SELECT
    TABNAME,        FIELDNAME,      POSITION,       KEYFLAG,        ROLLNAME,
    DATATYPE,       LENG
FROM  DD03L
WHERE TABNAME   = 'CSKS'
  AND AS4LOCAL  = 'A'
  AND FIELDNAME NOT LIKE '.%'
ORDER BY POSITION;

Comments

Popular posts from this blog

SAP S/4HANA Table Reference — Tables I Actually Query, by Topic

Production Order Variance Calculation KKS1 — Fixing KV031 and KV011, and What Lands in COSB

Modern ABAP Syntax Notes — Patterns and Pitfalls from Real Development