ZCO0042 — An ABAP Report That Unfolds CO Assessment Cycles (KSU1/KSU3) Including Allocation Structures
ZCO0042 is a custom ABAP report that unfolds the definition of CO actual assessment cycles (KSU1/KSU2/KSU3) into a single ALV grid. It is derived from ZCO0041, the sibling report for distribution cycles (KSV1/KSV3). The difference comes from what assessment does: it moves cost to a secondary cost element, so every segment carries either a single assessment cost element or an allocation structure, and the report shows that alongside the senders and receivers. In expanded mode, one row = segment × sender cost center × sender cost element × receiver × allocation-structure assignment.
Selection screen
The controlling area is pre-filled from the user parameter CAC (SU3) via MEMORY ID. The cycle F4 help cannot filter on T811C directly because that table has no KOKRS field; it goes through the cycle-level criteria in T811K (SETKIND = '0', FIELD = 'KOKRS') to restrict the list to the controlling area entered. The "only cycles with execution history" checkbox is hidden by default and toggled by typing =A in the command field. The allocation table is not a parameter: KSU1 always uses CCSS, so it is a constant.
Selection criteria Controlling area [CA10 ] to [ ] (from user parameter CAC) Cycle [ ] to [ ] F4: assessment cycles of that controlling area Start date [ ] to [ ] Additional options [ ] Only cycles with execution history (hidden until =A is typed) [ ] Expand sender/receiver groups and ranges (off = one row per segment)
Two output modes — summary and expansion
A single checkbox ("expand sender/receiver groups and ranges") switches between the two modes. Summary compresses each segment into one row: groups stay as group names, ranges stay as A~B, and a column that would hold several values shows *. Expansion resolves groups with the standard FM G_SET_GET_ALL_VALUES and ranges with the CSKB / CSKS masters, then shows every combination of the five axes listed above. The allocation-structure axis is included in the expansion: a segment with three assignments produces three times as many rows as the same senders and receivers alone.
Column layout
Three colored blocks make up the grid. Wherever a code appears, its name is placed next to it, and columns that are empty across the whole result are hidden from the start (they can be re-enabled in the layout).
| Block | Color | Columns |
|---|---|---|
| Sender | yellow (C300) | Sender rule, sender %, sender version, sender cost center (+ group), sender cost element (+ group) |
| Allocation structure | green (C500) | Allocation structure (+ name), assignment (+ name), source cost element (+ group), assessment cost element (+ group) |
| Receiver | orange (C700) | Receiver rule, variable portion type, negative tracing factor handling, receiver cost center / order (+ group), tracing factor, weighting factor, allocation base (+ group) |
Data sources — the T811 family
The cycle definition itself is stored in the same T811 tables as a distribution cycle. Assessment cycles have T811C-ALART = 'U'; the report reads TAB = 'CCSS' only (S/4HANA universal allocation cycles in ACDOC_CC / ACDOC_PC are out of scope).
| Table | Contents | Notes |
|---|---|---|
| T811C | Cycle header (key TAB / CYCLE / SDATE) | ALART 'U' = assessment, 'V' = distribution. No KOKRS field |
| T811S | Segments (SEQNR / NAME / SRULE / RRULE / SPERCENT / RCDATA / NEGTEST) | Plus ASACC (assessment cost element) or ABSCH (allocation structure) — only one of the two is used per segment |
| 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 (0 cycle, 1 sender control, 2 sender, 3 receiver, 4 receiver control = allocation base). Groups are stored as SETID, single values and ranges as VALMIN~VALMAX |
| T811F | Receiver tracing factors / weighting factors | SRFLAG 'R' = portion/percent (ELEMENT1 = receiver, VALUE = value), 'W' = weighting factor. If 'R' rows exist they replace the receiver list from T811K SETKIND 3; the group name from T811K is kept |
Allocation structure — where assessment departs from distribution
A segment either names a single assessment cost element (T811S-ASACC, e.g. cycle JNC2AA1010 posts everything to 8040) or refers to an allocation structure (T811S-ABSCH). With an allocation structure, the mapping source cost element → assessment cost element is defined per assignment, and that definition is spread across the TKB5 tables:
| Table | Contents | Key fields used |
|---|---|---|
| TKB5A | Allocation structure header | ABSCH |
| TKB5B | Allocation structure name (STEXT) | ABSCH |
| TKB5C | Assignments | ABSCH / ABZUO |
| TKB5D | Assignment name (ZTEXT) | ABSCH / ABZUO |
| TKB5E | Source cost elements per assignment | KSTAR_MIN~KSTAR_MAX range, or SETNR (a full SETID: class + subclass + group name) |
| TKB5AL | Assessment cost element per assignment | ASACC (single) or KSTARGER (cost element group) |
The report loads only the structures that are actually referenced by the selected segments (FOR ALL ENTRIES on ABSCH), then walks TKB5C per structure: the assignment name from TKB5D, the target from TKB5AL, and the sources from TKB5E. Because TKB5E stores its sources in the same shape as T811K (a SETID or a from/to range), the source rows are converted into a T811K work area and pushed through the same expand_key routine that expands sender groups and ranges. An assignment with neither a source nor a target is dropped from the output.
Example — cycle CA10AA0010 with allocation structure AS10
The test cycle in the sandbox is CA10AA0010, segment AA0010-010 (sender rule 1 = posted amounts, receiver rule 3 = fixed percentages, variable portion type WKGI). The segment refers to allocation structure AS10 instead of a single assessment cost element. The green block of the expanded output reads as follows:
Alloc.str Assignment Assignment name Source CE Assessment CE Assessment CE name AS10 A10 5070 8050 LABOR AS10 A20 5070 8050 LABOR AS10 A30 5080 8060 MACHINE
In summary mode the same segment collapses to one row and the assignment columns show *; double-clicking a sender, receiver, or allocation-structure column expands only that segment.
Program structure
The flow is read_cycles → read_keys_and_texts → build_rows → display_alv, the same skeleton as ZCO0041 with one additional routine for the allocation structure:
| FORM | Role |
|---|---|
| read_cycles | T811C ⨝ T811S for ALART='U', TAB='CCSS'; ASACC/ABSCH per segment kept in a side table; optional execution-history filter |
| read_keys_and_texts | Bulk-load T811K / T811F / T811L, then TKB5B/C/D/E/AL for the referenced allocation structures |
| build_rows | Per segment: classify T811K by SETKIND, expand groups/ranges, cross-join sender cost center × sender cost element × receiver × assignment (× allocation base) |
| build_alloc / sum_alloc | Expand the allocation structure into assignment × source rows (or one row for a single ASACC); summary-mode aggregation (1 value → value, more → *) |
| expand_key / expand_range | Group → G_SET_GET_ALL_VALUES (with a SETNAME → SETID fallback for older cycles); range → CSKB / CSKS |
| collect_factors / sum_factors / sum_weights | T811F portions and weighting factors; stored zero-value weighting rows are skipped |
| fill_texts / *_text | Names from CSKT / SKAT / CSLT / TKT03 / AUFK / SETHEADERT / TKB5B / TKB5D, cached in hashed tables; leading zeros stripped for display |
| display_alv / user_command / show_detail | Classic ALV (REUSE_ALV_GRID_DISPLAY), auto-hide empty columns, double-click → KSU3 or detail ALV |
Double-click behavior
| Where you double-click | What happens |
|---|---|
| Identification columns (controlling area, cycle, cycle name, start/end date, segment, segment name) | KSU3 is called for that cycle (SET PARAMETER ID CAC / KCY / GAS) |
| Any sender, allocation-structure, receiver, or allocation-base column | The single segment is expanded and shown in a second ALV (F3 returns to the summary) |
| Any column in the detail ALV | KSU3 for that cycle |
Differences from ZCO0041
| Aspect | ZCO0041 (distribution) | ZCO0042 (assessment) |
|---|---|---|
| Cycle type | T811C-ALART 'V' | T811C-ALART 'U' |
| Target cost element | None — original primary cost elements are kept | Assessment cost element (T811S-ASACC) or allocation structure (T811S-ABSCH, TKB5 tables) |
| Row axes in expanded mode | Segment × sender CCtr × sender CE × receiver | Same, plus × allocation-structure assignment |
| Column blocks | Sender (yellow), receiver (orange) | Sender (yellow), allocation structure (green), receiver (orange) |
| Allocation table parameter | Selectable (default CCSS) | Fixed to CCSS |
| Double-click target | KSV3 | KSU3 |
Things learned while building it
- The SPA/GPA parameter for the KSU3 cycle field is
KCY. The Cycle field on the KSU3 initial screen isRKAL1-KSCYC(length 6), not T811C-CYCLE.CYC(data element CCYCL) andGCY(CYCLE/GLCYC) belong to other fields, so values set there are ignored. - The value passed must be the 6-character cycle without the controlling-area prefix (JNC2AA1010 → AA1010). The controlling area goes to
CACand the start date toGAS. - Assignments with neither a source cost element nor an assessment cost element are excluded. Empty shells in an allocation structure only get in the way when reading the grid.
- it_sort controls value merging. With only cycle and segment in it_sort, every other column repeats its value on each row; registering all displayed columns makes consecutive equal values appear once. The current source deliberately keeps just CYCLE and SEQNR, because sorting several hundred thousand rows on dozens of keys was the largest bottleneck inside REUSE_ALV_GRID_DISPLAY.
- FOR ALL ENTRIES silently deduplicates. If the SELECT list does not include unique key columns, identical rows from different documents collapse into one.
The Korean original (with screenshots and the full source file ZCO0042_source.txt attached) is here: ABAP ZCO0042 — CO 배부 사이클(KSU1) 정의를 한 그리드로 펼치는 조회 리포트. The source is also available on request. The distribution-cycle counterpart is described in the post "ZCO0041 — An ABAP Report That Unfolds CO Distribution Cycles (KSV1/KSV3) into One Grid" on this blog.
Comments
Post a Comment