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.
| Line type | When it prints | Typical content |
|---|---|---|
| Detail | Each PRINT-selected record between breaks | Employee, transaction, item row |
| Subtotal | CONTROL field changes (per level) | Group label + SUM amounts |
| FINAL (grand total) | After last detail record | Report-wide SUM |
12345678910SORT 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.
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 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.
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.
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 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.
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.
1. Subtotals print when:
2. Lowest CONTROL field has break level:
3. When BRANCH and DEPT both change on one record:
4. SUMCTL DTLCOPY on level-1 break:
5. Subtotals require sorted input because: