ZCO0041 — An ABAP Report That Unfolds CO Distribution Cycles (KSV1/KSV3) into One Grid
ZCO0041 is a custom ABAP report that unfolds the definition of CO actual distribution cycles (KSV1/KSV2/KSV3) into a single ALV grid. In KSV3 you have to open a cycle and walk through five tabs per segment (Segment Header, Senders/Receivers, Sender Values, Receiver Tracing Factor, Receiver Weighting Factors); this report flattens all of that into rows you can scan at once — one row = segment × sender cost center × sender cost element × receiver.
Selection screen
The cycle F4 help is filtered by the controlling area entered on the screen (read at F4 time with DYNP_VALUES_READ, since PAI hasn't run yet). The "only cycles with execution history" checkbox is normally hidden — typing =A in the command field toggles it. Inputs starting with / are intercepted by the kernel as system commands, which is why = is used.
Two output modes — summary and expansion
A single checkbox ("expand sender/receiver groups and ranges") switches between two modes. Summary compresses each segment into one row (multiple values show as *). Expansion resolves groups (via the standard FM G_SET_GET_ALL_VALUES) and ranges (via the CSKB / CSKS masters) into individual values and shows every combination. The group a value came from stays visible in its own column, so you can always trace the origin.
Column layout
The grid is split into a sender block (yellow) and a receiver block (orange). Wherever a code appears, the name is placed right next to it (cost center names, cost element names, group names, order names). Columns that are empty across the whole result are hidden automatically (they can be re-enabled in the layout).
Data sources — the T811 family
A cycle definition is spread across five T811 tables. Knowing which KSV3 tab maps to which table is the backbone of the report:
| Table | Contents | Notes |
|---|---|---|
| T811C | Cycle header (key TAB / CYCLE / SDATE) | Distribution = ALART 'V', assessment = 'U'. Classic CO-OM uses TAB='CCSS' |
| T811S | Segments (SEQNR / NAME / SRULE / RRULE / SPERCENT / RCDATA / NEGTEST) | Sender rule, receiver rule, variable portion type, negative tracing factor handling |
| T811L | Cycle / segment texts | SEQNR '0000' = cycle text, anything else = segment text |
| T811K | Selection criteria per segment | One table holds everything from cycle-level criteria to the allocation base — SETKIND tells them apart (below) |
| T811F | Receiver tracing factors / weighting factors | SRFLAG 'R' = portion/percent (ELEMENT1 = receiver, VALUE = value), 'W' = weighting factor |
T811K's SETKIND is the decoder ring:
| SETKIND | Role |
|---|---|
| 0 | Cycle-level criteria (e.g. controlling area — T811C itself has no KOKRS field) |
| 1 | Sender control (version, ...) |
| 2 | Sender (cost centers, cost elements) |
| 3 | Receiver (cost centers, orders) |
| 4 | Receiver control = allocation base (e.g. activity type, statistical key figure) |
Groups are stored as a SETID (class 4 + subclass 4 + group name); single values and ranges sit in VALMIN~VALMAX.
Codes → names
Every code column gets its name from the matching master. Internal keys padded with leading zeros (0000004010, 000000100160) are looked up first and stripped only for display:
| Code | Name source |
|---|---|
| Cost center (KOSTL) | CSKT |
| Cost element (KSTAR) | SKAT |
| Activity type (LSTAR) | CSLT |
| Statistical key figure (STAGR) | TKT03 |
| Order (AUFNR) | AUFK-KTEXT |
| Group (SETID) | SETHEADERT |
| Domain codes (SRULE / RRULE / ...) | DD07T (fixed-value texts), T811M (variable portion types) |
Program structure
The flow is read_cycles → read_keys_and_texts → build_rows → display_alv:
| FORM | Role |
|---|---|
| read_cycles | T811C ⨝ T811S for ALART='V'; optional execution-history filter (LASTEXEC) |
| read_keys_and_texts | Bulk-load T811K / T811F / T811L with FOR ALL ENTRIES |
| build_rows | Per segment: classify T811K by SETKIND, expand groups/ranges, cross-join sender × receiver axes |
| expand_key / expand_range | Group → G_SET_GET_ALL_VALUES; range → CSKB (cost elements) / CSKS (cost centers) |
| collect_factors / sum_* | T811F portions & weighting factors; summary-mode aggregation (1 value → value, more → *) |
| fill_texts / *_text | Attach names from the masters above, then strip leading zeros for display |
| display_alv / user_command | Classic ALV (REUSE_ALV_GRID_DISPLAY), auto-hide empty columns, double-click → KSV3 |
Things learned while building it
- FOR ALL ENTRIES silently deduplicates. If the SELECT list doesn't include unique key columns, identical rows from different documents collapse into one.
- T811S-NEGTEST stores different codes than the KSV1 screen shows (DB 1=Absolute, 2=ToZero, 3=Standard, 4=None, 6·7=Smallest). The standard converts them (CHANGE_NORM_INTO_INTERN) before display — reading the DB value straight into DD07T gives you the wrong text.
- The same group name can exist multiple times with different class/subclass. SETHEADERT lookups must use the full SETID (class + subclass + name), not just the name.
- The allocation base (T811K SETKIND 4) only applies when the receiver rule is variable portions (RRULE '1'). Fixed-percentage segments can still carry leftover criteria rows — showing them as an allocation base would mislead, so they are cleared.
- The default weighting factor 100 is never stored in T811F. Rows exist only where someone changed the value; if everything is default, the column hides itself.
- Report globals reset when you return to the selection screen. The
=Ahidden-option state is kept across restarts in ABAP session memory (EXPORT/IMPORT ... MEMORY ID).
The Korean original (with screenshots and the full source file attached) is here: ABAP ZCO0041 — CO 분배 사이클(KSV1) 정의를 한 그리드로 펼치는 조회 리포트. Related reference posts on this blog: the T-code, table, and ABAP syntax references all mention ZCO0041.
· How Sarah Joined a K-Dumpling Company and Became an SAP Genius — the business novel, 53 pages, $25
· The Dumpling Factory: Building a Complete SAP S/4HANA Company from Scratch — the build manual, 85 pages, $50
Comments
Post a Comment