A Comprehensive Guide to CO Tables in SAP

A Comprehensive Guide to CO Tables in SAP

The Controlling (CO) module in SAP is essential for managing and monitoring organizational costs. It helps in planning, reporting, and monitoring operations and costs within an organization. This guide will introduce you to the primary CO tables in SAP, explain their purposes and interconnections, and provide examples of SQL queries to extract different types of information from these tables.

Key CO Tables in SAP

  1. COEP (CO Object: Line Items)
    • Stores line items for controlling objects, including cost centers, internal orders, and more.
  2. COSP (CO Object: Cost Totals)
    • Contains total costs for controlling objects, aggregated at various levels (e.g., month, fiscal year).
  3. CSKS (Cost Center: Master Data)
    • Holds master data for cost centers, including cost center descriptions, controlling areas, and hierarchy levels.
  4. CSKV (Cost Center: Master Data – Time-Dependent)
    • Stores time-dependent master data for cost centers, such as validity periods and associated cost elements.
  5. COKP (CO Order: Master Data)
    • Contains master data for internal orders, including order descriptions, statuses, and controlling areas.
  6. COSS (CO Object: Posted Totals)
    • Holds posted totals for cost elements within controlling objects.
  7. AUFK (Order Master Data)
    • Stores master data for internal orders, including order types, statuses, and controlling areas.

How These Tables Are Interconnected

The CO tables in SAP are interconnected through key fields that enable efficient data management and retrieval. Here’s how they typically relate to each other:

  • Cost Center (KOSTL): This key links cost center master data (CSKS, CSKV) with line items (COEP) and cost totals (COSP).
  • Internal Order (AUFNR): Connects order master data (AUFK) with line items (COEP) and cost totals (COSS).
  • Controlling Area (KOKRS): A primary key that links various controlling objects and aggregates data across different controlling areas.

You might be interested to learn the difference between cleared and open items in SAP

Example SQL Queries

  1. Retrieve Basic Cost Center Information

To get basic information about cost centers, including master data and time-dependent details, you can join CSKS and CSKV:

SELECT
    CSKS.KOSTL AS Cost_Center,
    CSKS.LTEXT AS Cost_Center_Description,
    CSKS.KOKRS AS Controlling_Area,
    CSKV.DATBI AS Valid_To,
    CSKV.DATAB AS Valid_From
FROM
    CSKS
JOIN
    CSKV ON CSKS.KOSTL = CSKV.KOSTL
WHERE
    CSKS.KOKRS = '1000';  -- Specific Controlling Area
  1. Retrieve Line Items for Controlling Objects

To get line items for controlling objects such as cost centers or internal orders, query the COEP table:

SELECT
    COEP.KOKRS AS Controlling_Area,
    COEP.KOSTL AS Cost_Center,
    COEP.AUFNR AS Internal_Order,
    COEP.GJAHR AS Fiscal_Year,
    COEP.MENGE AS Quantity,
    COEP.WRBTR AS Amount
FROM
    COEP
WHERE
    COEP.KOKRS = '1000'  -- Specific Controlling Area
    AND COEP.GJAHR = '2023';  -- Specific Fiscal Year
  1. Retrieve Total Costs for Controlling Objects

To get aggregated cost totals for controlling objects, query the COSP table:

SELECT
    COSP.KOKRS AS Controlling_Area,
    COSP.KOSTL AS Cost_Center,
    COSP.AUFNR AS Internal_Order,
    COSP.GJAHR AS Fiscal_Year,
    COSP.KSTAR AS Cost_Element,
    COSP.WTG001 AS Total_Cost
FROM
    COSP
WHERE
    COSP.KOKRS = '1000'  -- Specific Controlling Area
    AND COSP.GJAHR = '2023';  -- Specific Fiscal Year
  1. Retrieve Internal Order Master Data

To get master data for internal orders, query the AUFK and COKP tables:

SELECT
    AUFK.AUFNR AS Internal_Order,
    AUFK.KOKRS AS Controlling_Area,
    AUFK.AUART AS Order_Type,
    AUFK.AEDAT AS Created_On,
    COKP.ALTKT AS Cost_Center
FROM
    AUFK
JOIN
    COKP ON AUFK.AUFNR = COKP.AUFNR
WHERE
    AUFK.KOKRS = '1000';  -- Specific Controlling Area
  1. Retrieve Posted Totals for Cost Elements

To get posted totals for cost elements within controlling objects, query the COSS table:

SELECT
    COSS.KOKRS AS Controlling_Area,
    COSS.KOSTL AS Cost_Center,
    COSS.AUFNR AS Internal_Order,
    COSS.KSTAR AS Cost_Element,
    COSS.WTG001 AS Posted_Total
FROM
    COSS
WHERE
    COSS.KOKRS = '1000'  -- Specific Controlling Area
    AND COSS.KOSTL = '2000';  -- Specific Cost Center

Conclusion

Understanding the structure and relationships of SAP CO tables is crucial for effectively managing and analyzing cost-related data. The tables COEP, COSP, CSKS, CSKV, COKP, COSS, and AUFK each play a significant role in the Controlling module. By mastering the joins and key fields, you can write efficient SQL queries to retrieve various types of information, aiding in better data analysis and decision-making.

Learn more about FI Tables in SAP

Similar Posts