Sap co

From 5throck/ai-workspace-standards · View interactive version

Sap co is an AI agent skill from the GitHub repository 5throck/ai-workspace-standards. Use when working on CO module tasks — cost center accounting, internal orders, CO-PA profitability analysis, or cost allocation. Provides process flows, key table relationships, common query patterns, field notes, SAP quirks, and customizing tables for the CO module.

How to use this skill

Skill file

CO Analyst Context — Controlling

Load this skill when activating the CO Analyst role. Provides deep domain knowledge for cost center accounting, internal orders, and profitability analysis.

Process Flow

Cost Incurrence:
  ├── FI -> CO: Allocation to CO objects (KOSTL, AUFNR, PRCTR) during FB01/MIRO posting
  ├── PP -> CO: Production Order confirmation -> Actual Cost allocation
  └── HR -> CO: Payroll allocation -> Cost Center

Cost Allocation:
  KSV5 (Actual Distribution) → KSU5 (Actual Assessment) → CO88 (WIP Settlement)

Profitability Analysis (CO-PA):
  SD Billing → KE21N (Direct CO-PA Posting) → KE30 (PA Report)

Key Table Relationships

CSKS (Cost Center Master)
  └─► CSKB (Cost Center - by Cost Element)

COAS (Internal Order Master)
  └─► COSP (Internal Order Planned Cost)
        └─► COEP (Internal Order Actual Cost Line)

CE1xxxx (CO-PA Actual Line Items - xxxx=Operating Concern)
  └─► CE2xxxx (CO-PA Planned Line Items)
CE4xxxx (CO-PA Segment Level)

AUFK (Order Master Header - common for Internal/Production Order)
COBK (CO Document Header)
  └─► COEJ / COEP (CO Document Line Item)

Common Query Patterns

-- Actual Cost Aggregation by Cost Center (Current Month)
SELECT kostl, kstar, wrttp, wkgbtr
  FROM cosp
  WHERE kokrs = '1000' AND gjahr = '2026' AND versn = '0' AND wrttp = '04'
  ORDER BY kostl ASCENDING

-- Internal Order Balance Search (Open Orders)
SELECT a~aufnr, a~ktext, b~kstar, b~wkgbtr
  FROM coas AS a JOIN cosp AS b ON a~aufnr = b~aufnr AND a~kokrs = b~kokrs
  WHERE a~kokrs = '1000' AND a~objnr NOT LIKE 'OR%TECO%' AND b~gjahr = '2026'

-- CO-PA Sales/Cost Search (Operating Concern 1000)
SELECT prctr, kdgrp, artnr, kwbrum, kwbhkm
  FROM ce11000
  WHERE gjahr = '2026' AND perde = '05'
  ORDER BY kwbrum DESCENDING

-- WIP (Work in Process) Status
SELECT aufnr, gjahr, versn, wip_value
  FROM cooi
  WHERE kokrs = '1000' AND gjahr = '2026' AND versn = '0'

Key Field Notes

| Table | Field | Description |

|-------|-------|-------------|

| COSP | WRTTP | Value Type: 01=Planned, 04=Actual, 11=Actual Allocation |

| COSP | WKGBTR | Amount (Local Currency) |

| COSP | KSTAR | Cost Element |

| CE1xxxx | PRCTR | Profit Center |

| CE1xxxx | KWBRUM | Sales Revenue |

| CE1xxxx | KWBHKM | Cost of Goods Sold (COGS) |

| COAS | OBJNR | Order Object Number (Key for Distribution/Assessment) |

CO-PA Structure

CO-PA has two types:

| Type | Table | Features |

|------|-------|----------|

| Account-based | ACDOCA | Recommended for S/4HANA, fully integrated with FI |

| Costing-based | CE1xxxx | Traditional, value-field based, real-time aggregation |

SAP Quirks & Known Issues

Standard Customizing Tables

| Table | Purpose |

|-------|---------|

| TKA01 | Controlling Area |

| CSLA | Activity Type Master |

| TKA05 | Version (Planned/Actual) |

| TKEV | CO-PA Operating Concern |

| TKE1 | CO-PA Characteristic Definition |

Strategic BAPIs & APIs

Cost Center Creation (Multiple)

BAPI: BAPI_COSTCENTER_CREATEMULTIPLE

Cost Center Change

BAPI: BAPI_COSTCENTER_CHANGE

Internal Order Create

BAPI: BAPI_INTERNALORDER_CREATE

Internal Order Change

BAPI: BAPI_INTERNALORDER_CHANGE

Context

This skill provides the CO Analyst with comprehensive domain knowledge for the Controlling module in SAP. It is loaded when the active task involves cost center accounting, internal order management, CO-PA profitability analysis, or cost allocation cycles. The skill covers cost flows, CO-PA structures, query patterns, and standard BAPIs for controlling operations.

When to Use

Execution Steps

  1. Review the Process Flow section to understand cost incurrence sources (FI, PP, HR) and the allocation chain.
  2. Query key tables using the Key Table Relationships section — identify operating concern from TKA01 for CE1xxxx table naming.
  3. Apply Common Query Patterns for cost center aggregation, internal order balances, CO-PA profitability, and WIP status.
  4. Check SAP Quirks & Known Issues for CE1xxxx naming conventions, cost element integration (S/4HANA vs Classic), and allocation tracing.
  5. Review the CO-PA Structure section to determine account-based vs costing-based approach in the target system.
  6. Leverage Strategic BAPIs & APIs for cost center and internal order creation and modification.

Output Format

Structured analysis output should include: controlling area context, cost object references (KOSTL/AUFNR/PRCTR), planned vs actual comparison tables, allocation cycle summaries, and CO-PA profitability breakdowns by characteristic. Include variance analysis with root-cause indicators.

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.