Easytrieve Control Break Processing Pattern

Department subtotals. Region banners. Page breaks when warehouse code changes. Control break processing is the beating heart of Easytrieve reporting—and the number one source of wrong totals in beginner programs. The product compares each detail record to the prior row's CONTROL field values; when REGION changes from East to West, break processing closes the East group, prints subtotals, runs your BEFORE-BREAK and AFTER-BREAK PROCs, opens West, and continues detail. That only works when East rows are adjacent—sorted input. The control break processing pattern is how experienced shops wire SORT, CONTROL major-to-minor, reusable break PROCs, SUM quantitative fields, and FINAL grand totals into every listing without reinventing LEVEL logic. This page teaches pattern architecture, sort key alignment, framework PROCs for break banners, NOPRINT and NEWPAGE options, SUMCTL integration, multi-level break testing, pairing with reusable report framework headings, and debugging subtotals that do not foot.

Progress0 of 0 lessons

Pattern Architecture

Control break processing stack
StepActivityResponsibility
1SORT inputKeys match CONTROL major-to-minor
2REPORT CONTROLDeclare break fields and options
3LINE detailQuantitative fields with SUM
4BEFORE-BREAK / AFTER-BREAKFramework PROC hooks
5FINALGrand totals end of report

Sort Alignment

CONTROL REGION BRANCH DEPT requires input sorted REGION, BRANCH, DEPT all ascending unless documentation allows otherwise. SORT activity KEY order must match CONTROL order exactly—swapping BRANCH before REGION inverts hierarchy and LEVEL semantics. External sort JCL step before Easytrieve is valid when data too large for internal SORT. Document sort keys in report spec next to CONTROL line so maintainers do not drop a key during enhancement.

text
1
2
3
4
5
6
7
8
9
SORT USING DETAIL-FILE GIVING SORTED-WORK KEY REGION ASCENDING BRANCH ASCENDING DEPT ASCENDING END-SORT REPORT SALES-LISTING JOB INPUT SORTED-WORK CONTROL REGION NEWPAGE BRANCH DEPT LINE ITEM-ID QTY-SOLD MASK NUM-MASK SUM END-REPORT

CONTROL Options in Pattern

NEWPAGE

CONTROL REGION NEWPAGE starts each major region on fresh page—common in framework when STD-HEADING reprints. Coordinate with reusable report framework PAGE procedures so page numbers continue correctly.

RENUM

Renumbers detail lines within break group when LINE uses sequence display—audit reports numbering rows per department reset to one.

NOPRINT

CONTROL DEPT NOPRINT accumulates department totals but suppresses printed department subtotal line—use when only region-level subtotals should appear while DEPT still drives minor break for counters in AFTER-BREAK.

FINAL

FINAL options on CONTROL govern grand total line at report end—framework STD-FINAL-LINE macro prints consistent grand total mask across reports.

LEVEL and BREAK-LEVEL in Framework PROCs

text
1
2
3
4
5
6
7
8
9
BEFORE-BREAK. PROC IF LEVEL EQ 1 PERFORM STD-REGION-BANNER END-IF IF LEVEL EQ 2 PERFORM STD-BRANCH-BANNER END-IF PERFORM RESET-BREAK-COUNTERS END-PROC

LEVEL is system field indicating which CONTROL field triggered current break. STD-REGION-BANNER prints LINE from framework using prior REGION value saved before break. RESET-BREAK-COUNTERS clears working storage counts used in custom analytics—not quantitative SUM fields product maintains automatically. BREAK-LEVEL identifies highest field that broke when multiple change—useful in AFTER-BREAK for diagnostic DISPLAY when DEBUG-FLAG set.

Quantitative Fields and SUM

LINE declares amount fields with SUM option—product accumulates per control group and FINAL. Pattern keeps money MASKs in framework macro MONEY-MASK. Do not COMPUTE running totals in PROC when SUM handles it—double counting risk. Custom non-LINE accumulators in AFTER-BREAK when SUM insufficient—for example distinct count of customers requires user-maintained SET table simulation with working storage arrays sized per release limits.

AFTER-BREAK Framework

AFTER-BREAK runs after subtotal lines for break print—use for audit stamps, PERFORM WRITE-AUDIT-RECORD with break key and subtotal snapshot, or DISPLAY when DEBUG. STD-AFTER-BREAK might MOVE break totals to statistics file for data warehouse extract parallel to printed report.

Pairing With Reusable Report Framework

TITLE and HEADING from STD-REPORT-HEADING macro; CONTROL break banners in BEFORE-BREAK from STD-BREAK-PROC library; FOOTING from STD-FOOTING. Business report supplies only CONTROL field names, SORT keys, and detail LINE fields. Changing banner asterisk line width happens once in framework—every regional report updates.

Multi-Level Break Example

text
1
2
3
4
5
6
7
8
9
10
REPORT PAYROLL-REGISTER CONTROL DIVISION NEWPAGE DEPARTMENT HEADING LINE 'EMP' COL 1 'NAME' COL 10 'GROSS' COL 40 LINE EMP-NO EMP-NAME GROSS-PAY MASK MONEY-MASK SUM BEFORE-BREAK PERFORM STD-BEFORE-BREAK AFTER-BREAK PERFORM STD-AFTER-BREAK END-REPORT

DIVISION major break pages; DEPARTMENT minor break subtotals within division. Employee detail prints between breaks. Test with small file where division changes once and department changes twice within first division.

SUMCTL Pattern

When multiple reports or activities share control totals, SUMCTL fields synchronize accumulation across report subactivities per Broadcom SUMCTL documentation. Pattern uses SUMCTL for job-level control record written at TERM matching sum of report FINAL lines—audit tie-out. Beginners skip SUMCTL until multi-report JOB requires cross-report total agreement.

Debugging Wrong Subtotals

  1. Verify SORT key order matches CONTROL order character by character.
  2. DISPLAY first key change positions—find out-of-sequence adjacent pairs.
  3. Confirm quantitative fields on LINE include SUM.
  4. Check NOPRINT not hiding line you expect to see.
  5. Compare manual spreadsheet pivot to FINAL line.

Testing Pattern

  1. Three rows same DEPT then change—one break, one subtotal.
  2. NEWPAGE region: page break count increments in FOOTING.
  3. LEVEL-specific BEFORE-BREAK banner appears only at correct break.
  4. Empty input: FINAL only or title per design.
  5. Regression compare to golden listing after framework change.

Common Mistakes

  • Unsorted input—false breaks or missing breaks.
  • CONTROL field order not major-to-minor.
  • Quantitative field with decimals in CONTROL—invalid; use non-quantitative keys.
  • Manual totals duplicating SUM.
  • BEFORE-BREAK logic that assumes wrong LEVEL number.
  • SORT omitted when extract order not guaranteed.

Explain It Like I'm Five

Kids line up by class then by team color. When red team ends and blue team starts, the teacher announces red team's score before blue team continues. Control break processing is that announcement rule—but kids must already stand in class and color order or the teacher announces scores at the wrong time. SORT is lining up; CONTROL is which labels to watch; BEFORE-BREAK is what the teacher says when a group ends.

Exercises

  1. Write SORT keys and CONTROL fields for REGION BRANCH DEPT—same order.
  2. Sketch BEFORE-BREAK with LEVEL 1 and 2 PERFORM branches.
  3. Explain NOPRINT on minor CONTROL when only major subtotals print.
  4. Design test file with four records proving two break levels.
  5. List three checklist items when subtotals do not match spreadsheet.

Quiz

Test Your Knowledge

1. Control break processing requires input:

  • Sorted into CONTROL field major-to-minor order
  • Random order
  • Unloaded from SQL only
  • Without FILE

2. CONTROL fields are listed:

  • Major-to-minor hierarchy
  • Alphabetic field name order only
  • Descending length only
  • Inside TITLE only

3. BEFORE-BREAK PROC runs:

  • When a control break occurs before subtotal lines print
  • At JOB start only
  • In SCREEN AFTER-SCREEN
  • At compile time

4. Framework subtotal PROC might:

  • Print standard break banner and reset working counters
  • Replace SORT
  • Open JCL
  • Disable LINE

5. NOPRINT on a CONTROL field:

  • Suppresses printing summary line for that break level
  • Skips all detail
  • Disables FINAL
  • Removes SORT
Published
Read time17 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve CONTROL BEFORE-BREAK AFTER-BREAK report processingSources: Broadcom Easytrieve 11.6 Report Generator CONTROL LEVEL BREAK-LEVEL proceduresApplies to: Easytrieve control break processing design pattern