Easytrieve Report Subtotals

Grand totals answer how much for the entire company; subtotals answer how much for each department, branch, or region along the way. Easytrieve subtotals are not a separate statement—you produce them with CONTROL hierarchy, SUM accumulation, and LINE layout interpreted by the report writer at each break. When DEPT changes from 100 to 200, the writer prints a subtotal line for department 100's GROSS and NET-PAY, then begins accumulating department 200. When BRANCH changes, a higher subtotal may print that rolls up all departments under the closing branch—a larger subtotal line with branch label and branch-level sums. LEVEL in BEFORE-BREAK tells your procedure whether the imminent print is a zip-level row or a state-level row so you format labels and percentages correctly. Beginners achieve one subtotal level quickly with CONTROL DEPT but struggle with three levels because SORT keys, CONTROL order, SUMCTL, and CONTROLSKIP must align. This page focuses on subtotal behavior between detail and FINAL—multi-level closure order, line content, NOPRINT at intermediate levels, and testing hierarchical listings auditors expect.

Progress0 of 0 lessons

Subtotal Versus Detail Versus FINAL

Three line types in a control report
Line typeWhen it printsTypical content
DetailEach PRINT-selected record between breaksEmployee, transaction, item row
SubtotalCONTROL field changes (per level)Group label + SUM amounts
FINAL (grand total)After last detail recordReport-wide SUM

Multi-Level Example

text
1
2
3
4
5
6
7
8
9
10
SORT PERSNL TO SORTWK USING (REGION, BRANCH, DEPT) JOB INPUT SORTWK PRINT PAY-RPT REPORT PAY-RPT LINESIZE 132 CONTROLSKIP 1 TITLE 01 'PAYROLL BY REGION / BRANCH / DEPT' LINE 01 REGION BRANCH DEPT EMPNO GROSS CONTROL REGION BRANCH DEPT SUM GROSS

Sorted input ensures all DEPT 100 rows are adjacent. Subtotal for DEPT prints when DEPT changes; subtotal for BRANCH when BRANCH changes (closing all depts in that branch); subtotal for REGION when REGION changes. Each subtotal line shows SUM GROSS for the closing group. CONTROLSKIP 1 separates subtotal block from next detail visually.

Break Level Processing

LEVEL = 1 typically corresponds to DEPT—the lowest CONTROL field. LEVEL = 2 to BRANCH, LEVEL = 3 to REGION in a three-field CONTROL list. BEFORE-BREAK can set SUBTOTAL-LABEL literal or computed percent: IF LEVEL = 1 MOVE 'DEPT TOTAL' TO LABEL-FIELD; IF LEVEL = 2 MOVE 'BRANCH TOTAL' TO LABEL-FIELD. Field HIGHEST-BREAK on REGION is true when region boundary closes even if DEPT also changed—procedure should handle outer-level messaging once.

SUMCTL and Subtotal Line Content

SUMCTL ALL prints each control field value on every subtotal line—DEPT, BRANCH, and REGION may all appear on a DEPT-level row depending on configuration. HIAR shows hierarchical context—branch and region on department subtotal. NONE minimizes control value repetition when LINE layout already shows keys. DTLCOPY adds detail field snapshot on LEVEL 1 subtotals—last employee name before zip subtotal in Broadcom examples—useful when subtotal line must show who closed the group.

Suppressing Intermediate Subtotals

CONTROL BRANCH NOPRINT still accumulates branch totals feeding region subtotals but skips printing branch subtotal line group—only DEPT and REGION lines appear. Use when policy wants department and region subtotals without branch lines on paper. BEFORE-BREAK still runs for NOPRINT levels—adjust percentages there even when line is hidden.

Subtotal LINE Design

Detail LINE 01 lists full columns. Subtotal rows often reuse LINE layout—control fields first, SUM fields aligned under detail amount columns via POS on multi-line groups. Some shops add LINE 02 only on break via BEFORE-BREAK setting print switch or use dedicated literals in TITLE-like break headers per release. Keep column alignment under 132 or 80 LINESIZE so auditors tie subtotal GROSS column under detail GROSS column.

REPORT-INPUT and Subtotal Population

REPORT-INPUT SELECT filters which records enter report accumulation. Records not SELECTed do not affect subtotals. If subtotals disagree with file totals, verify SELECT in REPORT-INPUT versus JOB IF before PRINT—both must represent same population.

Common Subtotal Mistakes

  • Unsorted input—multiple subtotals for same DEPT.
  • Wrong CONTROL order—branch subtotal before department logic expects.
  • Missing SUM—unexpected columns auto-total on subtotal lines.
  • Ignoring LEVEL in BEFORE-BREAK—wrong label on multi-level break.
  • Expecting subtotal across non-contiguous same key groups.

Testing Subtotals

  1. Small sorted file with two DEPT values—verify one DEPT subtotal between groups.
  2. Force BRANCH change without DEPT change—verify branch subtotal only.
  3. Compare sum of DEPT subtotals to FINAL grand total.
  4. Test NOPRINT intermediate level—region still correct when branch line suppressed.

Explain It Like I'm Five

Subtotals are mini answers in the middle of the worksheet. Each time the class name changes, you write how many points that class got before starting the next class. Bigger subtotals are when the whole grade level changes—you add up all classes in that grade. Little subtotals nest inside big ones, like Russian dolls of addition problems.

Exercises

  1. Design three-level CONTROL with matching SORT USING keys.
  2. Write BEFORE-BREAK pseudocode using LEVEL for two labels.
  3. Explain NOPRINT on middle CONTROL level effect on printed lines.
  4. Describe DTLCOPY value on level-1 subtotal row.
  5. Reconcile DEPT subtotals sum to FINAL GROSS on paper example.

Quiz

Test Your Knowledge

1. Subtotals print when:

  • A CONTROL field value changes before the next detail
  • Every TITLE line
  • JOB compiles
  • FILE closes

2. Lowest CONTROL field has break level:

  • 1 (most frequent subtotals)
  • 99 always
  • Same as FINAL
  • Zero

3. When BRANCH and DEPT both change on one record:

  • Multiple break levels may process for that boundary
  • Only DEPT breaks
  • No subtotals
  • Compile error

4. SUMCTL DTLCOPY on level-1 break:

  • Prints detail field values on lowest subtotal line
  • Suppresses all subtotals
  • Sorts input
  • Opens SQL

5. Subtotals require sorted input because:

  • Breaks compare consecutive records only
  • SORT compiles REPORT
  • TITLE requires SORT
  • SUMCTL requires SORT
Published
Read time17 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 Control Reports SUMCTL LEVEL BEFORE-BREAKSources: Broadcom Easytrieve 11.6 Control Reports, CONTROL Statement, SUM StatementApplies to: Easytrieve multi-level report subtotals