BEFORE-BREAK is not a standalone executable statement you sprinkle in JOB logic—it is a special-name report procedure the report writer calls automatically before printing CONTROL summary lines. When DEPT or REGION changes on a sorted file, Easytrieve accumulates SUM totals, then needs percentages and averages that depend on those totals. Those values must exist immediately before the total line prints—BEFORE-BREAK is that hook. You code BEFORE-BREAK. PROC after the REPORT block, terminated with END-PROC, and populate fields referenced on summary LINE statements such as PERCENT or custom annotations. System fields LEVEL, BREAK-LEVEL, and field-class BREAK tests such as BRANCH HIGHEST-BREAK tell you which break level is active so one PROC can branch for branch-only versus region-plus-final totals. BEGINNERS confuse BEFORE-BREAK with BEFORE-LINE—LINE runs before each detail row; BREAK runs before subtotal rows. This page teaches syntax, placement, LEVEL semantics, calculation patterns, NOPRINT interaction, and testing control reports with multi-level CONTROL fields.
Broadcom documents the format as the reserved procedure label followed by PROC. The body contains normal Activity statements—assignments, IF, DISPLAY—and must close with END-PROC. You do not PERFORM BEFORE-BREAK; the report processor invokes it when CONTROL breaks fire.
123BEFORE-BREAK. PROC PERCENT = PAY-NET * 100 / TOTAL-NET END-PROC
Report PROCs follow the REPORT subactivity declaration—REPORT name, TITLE, LINE, CONTROL, SUM—and precede or follow sibling report PROCs in the block the manual diagrams. Job PROCs coded with PERFORM sit before REPORT; BEFORE-BREAK sits after REPORT lines. Mixing report PROCs among executable JOB statements causes compile errors about procedure placement.
12345678910111213JOB INPUT PAYROLL TOTAL-NET = TOTAL-NET + PAY-NET PRINT REPORT1 REPORT REPORT1 LINESIZE 80 SUMMARY SUMCTL DTLCOPY SEQUENCE STATE ZIP LAST-NAME CONTROL STATE ZIP LINE 01 LAST-NAME STATE ZIP PAY-NET PERCENT BEFORE-BREAK. PROC PERCENT = PAY-NET * 100 / TOTAL-NET END-PROC
| Event | Typical procedure | Purpose |
|---|---|---|
| Record selected for report | REPORT-INPUT | Further SELECT or field prep |
| Before detail line print | BEFORE-LINE | Modify detail fields |
| After detail line print | AFTER-LINE | Annotations below detail |
| Before control summary lines | BEFORE-BREAK | Finalize break calculations |
| After control summary lines | AFTER-BREAK | Post-break cleanup or notes |
With two CONTROL fields—REGION major, BRANCH minor—multiple summary lines may print on one break. LEVEL indicates which summary line is next; BREAK-LEVEL indicates the highest control field breaking. Broadcom CONTROL Reports example: when LEVEL is 1 and BREAK-LEVEL is 1, only branch totals print next; when BREAK-LEVEL is 2, branch and region totals print; when BREAK-LEVEL is 3, final report totals follow. Use IF LEVEL = 1 to run logic only on the lowest break line, or test field HIGHEST-BREAK for readable messages.
1234567891011BEFORE-BREAK. PROC IF BRANCH BREAK IF BRANCH HIGHEST-BREAK DISPLAY '*** BRANCH TOTALS ***' ELSE-IF REGION HIGHEST-BREAK DISPLAY '*** BRANCH AND REGION TOTALS ***' ELSE-IF BREAK-LEVEL = 3 DISPLAY '*** FINAL TOTALS ***' END-IF END-IF END-PROC
Grand totals for denominators often live in S storage or accumulators maintained during JOB INPUT. TALLY counts items for averages. Compute PERCENT = break-sum * 100 / grand-total in BEFORE-BREAK because SUM fields hold break subtotals only after accumulation completes. Division by zero when grand total is zero—guard with IF TOTAL-NET GT 0. ROUNDED on assignment matches currency display on summary LINE.
CONTROL with NOPRINT suppresses printing summary lines but Broadcom states BEFORE-BREAK still executes. Use this when you need calculations or DISPLAY diagnostics without visible total lines, or when custom LINE logic replaces default SUM output. Verify layout with small test file—operators expect totals when NOPRINT is accidental.
With two control fields, minor field break invokes BEFORE-BREAK once; major field break may invoke it twice as each level summary prepares. Design side-effect-free logic or use LEVEL tests so messages and assignments run at intended levels only.
Broadcom limits some file I/O inside report PROCs during sort or report processing. Prefer calculations and DISPLAY in BEFORE-BREAK; defer GET and PUT to JOB logic when documentation warns against I/O in report PROC context. KEEP procedures short for maintainability.
Imagine a teacher stacking blocks by color before writing the count on the board. BEFORE-BREAK is the moment right before the teacher writes the count—they figure out what fraction of all blocks this color pile is. The report robot calls BEFORE-BREAK by itself whenever a new color pile is ready for its number on the board. You do not shout BEFORE-BREAK; you just write the recipe inside it.
1. BEFORE-BREAK. PROC runs:
2. LEVEL system field indicates:
3. If NOPRINT is on CONTROL, BEFORE-BREAK:
4. BEFORE-BREAK must end with:
5. Typical BEFORE-BREAK calculation: