Easytrieve BEFORE-BREAK Statement

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.

Progress0 of 0 lessons

Statement Format

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.

text
1
2
3
BEFORE-BREAK. PROC PERCENT = PAY-NET * 100 / TOTAL-NET END-PROC

Placement in REPORT Structure

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.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
JOB 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

When BEFORE-BREAK Fires

Report writer timing
EventTypical procedurePurpose
Record selected for reportREPORT-INPUTFurther SELECT or field prep
Before detail line printBEFORE-LINEModify detail fields
After detail line printAFTER-LINEAnnotations below detail
Before control summary linesBEFORE-BREAKFinalize break calculations
After control summary linesAFTER-BREAKPost-break cleanup or notes

LEVEL and BREAK-LEVEL

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.

text
1
2
3
4
5
6
7
8
9
10
11
BEFORE-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

Percentage and Average Calculations

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.

NOPRINT on CONTROL

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.

Multi-Level Break Invocation Count

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.

Restrictions and I/O

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.

Testing BEFORE-BREAK Logic

  1. Sort input by CONTROL field order before JOB run.
  2. Verify PERCENT and averages against spreadsheet on small file.
  3. Test single break level then add second CONTROL field.
  4. Confirm DISPLAY messages appear once per expected break.
  5. Test edge case: one record per break, empty file, zero grand total.

Common BEFORE-BREAK Mistakes

  • Confusing BEFORE-BREAK with BEFORE-LINE detail hook.
  • PERFORM attempting to call BEFORE-BREAK manually.
  • Placing PROC before REPORT block.
  • Computing percent before grand total accumulator complete.
  • Ignoring LEVEL—running branch message on final totals.
  • Division by zero on empty report grand total.

Explain It Like I'm Five

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.

Exercises

  1. Write BEFORE-BREAK computing PERCENT from break PAY-NET and TOTAL-NET.
  2. Add DISPLAY message when REGION HIGHEST-BREAK using field-class test.
  3. Explain difference between BEFORE-BREAK and AFTER-BREAK timing.
  4. Draw CONTROL sequence for REGION and BRANCH two-level report.
  5. Guard percent assignment when TOTAL-NET is zero.

Quiz

Test Your Knowledge

1. BEFORE-BREAK. PROC runs:

  • Before summary lines for a control break print
  • Before every detail line
  • At program compile
  • Only in JCL

2. LEVEL system field indicates:

  • Which control break level is processing
  • JCL return code
  • File record length
  • Screen row number

3. If NOPRINT is on CONTROL, BEFORE-BREAK:

  • Still executes
  • Never runs
  • Compile error
  • Closes the file

4. BEFORE-BREAK must end with:

  • END-PROC
  • END-IF
  • END-REPORT
  • STOP

5. Typical BEFORE-BREAK calculation:

  • Percent of break total versus grand total
  • Sort key assignment
  • FILE definition
  • OPEN printer
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 BEFORE-BREAK report procedureSources: Broadcom Easytrieve 11.6 Language Reference BEFORE-BREAK, Report Procedures, CONTROL ReportsApplies to: Easytrieve BEFORE-BREAK report procedure