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.
| Step | Activity | Responsibility |
|---|---|---|
| 1 | SORT input | Keys match CONTROL major-to-minor |
| 2 | REPORT CONTROL | Declare break fields and options |
| 3 | LINE detail | Quantitative fields with SUM |
| 4 | BEFORE-BREAK / AFTER-BREAK | Framework PROC hooks |
| 5 | FINAL | Grand totals end of report |
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.
123456789SORT 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 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.
Renumbers detail lines within break group when LINE uses sequence display—audit reports numbering rows per department reset to one.
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 options on CONTROL govern grand total line at report end—framework STD-FINAL-LINE macro prints consistent grand total mask across reports.
123456789BEFORE-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.
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 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.
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.
12345678910REPORT 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.
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.
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.
1. Control break processing requires input:
2. CONTROL fields are listed:
3. BEFORE-BREAK PROC runs:
4. Framework subtotal PROC might:
5. NOPRINT on a CONTROL field: