Easytrieve TOTAL — Report Accumulation and Control Breaks

New Easytrieve programmers hear TOTAL in three contexts: a reserved word they cannot use as a field name, an assignment expression like WS-TOTAL = WS-TOTAL + GROSS, and a report feature that prints department subtotals and grand totals at the bottom. Broadcom Easytrieve Report Generator 11.6 Language Reference does not define a standalone TOTAL statement—the way it defines SUM, CONTROL, or LINE. Instead, the product totals quantitative fields automatically on control reports when those fields appear on LINE statements with decimal positions, and CONTROL declares when subtotals print. SUM narrows which fields participate. This page teaches that full totals pipeline: CONTROL hierarchy, default LINE totaling, SUM overrides, FINAL grand totals, SUMCTL annotation on total lines, REPORT SUMMARY-only layouts, and how procedural ADD differs from declarative report accumulation. Beginners who expect TOTAL field-name syntax like COBOL REPORT SECTION will map faster once they see CONTROL plus SUM as the Easytrieve idiom.

Progress0 of 0 lessons

No Standalone TOTAL Statement

Searching the 11.6 statements index finds SUM, CONTROL, LINE, and REPORT—not TOTAL as an executable verb. Tutorial maps list TOTAL because report totaling is a first-class skill and shops say run the TOTAL report meaning the control-break version. When you see TOTAL in legacy source it is almost always a field identifier such as DEPT-TOTAL or GRAND-TOTAL, or an assignment target—not a keyword introducing a statement. Avoid naming fields TOTAL; reserved-word collisions fail compilation or confuse maintainers.

How Control Reports Produce Totals

Statements that create report totals
StatementRole in totaling
REPORTDeclares control report (default) or SUMMARY
SEQUENCEOrders input major-to-minor for breaks
CONTROLNames break fields; triggers subtotal lines
LINELists detail fields; quantitative ones total by default
SUMOptional—limits which fields are totaled

CONTROL Break Mechanics

text
1
2
3
4
5
REPORT PAY-RPT LINESIZE 80 SEQUENCE DEPT CONTROL DEPT TITLE 01 'PERSONNEL BY DEPARTMENT' LINE 01 DEPT EMPNAME GROSS NET-PAY DEDUCTIONS

SEQUENCE DEPT sorts input so all department 901 records appear before 902. CONTROL DEPT declares a break on department: when DEPT changes, Easytrieve prints a subtotal line accumulating every quantitative field on LINE—in this example GROSS, NET-PAY, and DEDUCTIONS because they carry decimal positions. Non-quantitative fields like EMPNAME do not sum—they may repeat or blank on total lines per SUMCTL settings. At end of file, FINAL grand totals print automatically unless FINAL NOPRINT suppresses them.

SUM — Restricting Which Fields Total

text
1
2
3
4
5
6
REPORT PAY-RPT LINESIZE 80 SEQUENCE DEPT CONTROL DEPT SUM GROSS TITLE 01 'SALARY EXPENSE BY DEPT' LINE 01 DEPT EMPNAME GROSS NET-PAY DEDUCTIONS

SUM GROSS overrides default LINE behavior. Only GROSS accumulates and prints on subtotal and FINAL lines. NET-PAY and DEDUCTIONS still appear on detail rows but do not contribute to control totals. SUM fields need not appear on LINE—you can SUM a working-storage accumulator never shown on detail. SUM is valid only on control reports, coded after REPORT with other definition statements.

CONTROL Options: NEWPAGE, NOPRINT, FINAL

CONTROL subparameters
OptionEffect on totals
NEWPAGEPage break after printing break totals (or before FINAL totals)
NOPRINTAccumulate but do not print subtotal line for that field level
RENUMPage break and restart page numbering at 1
FINAL NOPRINTSuppress grand total line printing

Multi-level CONTROL STATE ZIP breaks subtotals at state then zip within state. List fields major-to-minor on one CONTROL statement. Hierarchical SUMCTL on REPORT controls how control field values annotate each total line—ALL prints every control value on every total line; HIAR prints hierarchical values; TAG adds control-field-name TOTAL text to the left of totals.

REPORT SUMMARY — Totals Without Detail

REPORT SUMMARY on the REPORT statement suppresses detail LINE output. Only control total lines print—useful for executive summaries showing department salary totals without employee names. SUM still governs which quantitative fields appear in those total lines. SUMMARY pairs with CONTROL multi-level breaks to produce nested subtotals only.

Procedural Totals Versus Report Totals

Inside JOB activities, ADD GROSS TO WS-GRAND-TOTAL or GRAND-TOTAL = GRAND-TOTAL + GROSS builds running totals you DISPLAY or WRITE yourself—Easytrieve report writer is not involved. PRINT RPT1 hands records to a report that may separately CONTROL-total the same GROSS field on the LINE. The two mechanisms can coexist: procedural accumulators for validation thresholds, report CONTROL for formatted subtotals. Do not assume ADD updates report total lines—only CONTROL processing does.

BEFORE-BREAK and AFTER-BREAK Procedures

Report procedures BEFORE-BREAK and AFTER-BREAK run around control break processing. AFTER-BREAK might compute PERCENT = BREAK-NET * 100 / GRAND-NET using accumulators the report writer maintains. These hooks customize total lines beyond default SUMCTL formatting—see report events tutorials for procedure naming by break level.

TOTAL as Reserved Word and Field Naming

Language rules treat TOTAL as reserved. Name accumulators WS-GRAND-TOTAL, DEPT-SUM-GROSS, or RUN-ACCUM instead. Interview questions sometimes trap candidates who declare DEFINE TOTAL W 9 P 2. Prefix working-storage names with WS- or RUN- per shop standards to avoid reserved-word tables entirely.

Common TOTAL Mistakes

  • Searching for a TOTAL statement keyword instead of CONTROL and SUM.
  • CONTROL without SEQUENCE on unsorted input—breaks fire at wrong records.
  • Expecting alphabetic fields on LINE to sum—they must be quantitative.
  • Forgetting SUM when only one of several LINE amounts should total.
  • Mixing procedural ADD with expectation that report totals match without PRINT.
  • Using field name TOTAL and hitting reserved-word compile errors.

Explain It Like I'm Five

Imagine sorting marbles by color in a jar. Every time the color changes, you count how many marbles of the old color you saw and write the count on a sticky note—that is a subtotal. CONTROL tells Easytrieve when the color changed. LINE shows each marble; amounts with decimals get added on the sticky note. SUM says only count the big marbles, not the small ones. At the end you add all sticky notes for a grand total—that is FINAL. There is no magic word TOTAL to say— you use CONTROL and SUM instead.

Exercises

  1. Write a CONTROL DEPT report totaling all LINE quantitative fields by default.
  2. Add SUM GROSS so NET-PAY no longer appears on subtotal lines.
  3. Diagram SEQUENCE versus CONTROL for a STATE then ZIP two-level report.
  4. Rename a field called TOTAL to WS-ACCUM-AMT and explain why.
  5. Contrast ADD TO in JOB with SUM on REPORT in three sentences.

Quiz

Test Your Knowledge

1. Is TOTAL a standalone report statement in Easytrieve 11.6?

  • No — totals come from CONTROL/SUM/LINE; TOTAL is often a field name
  • Yes — TOTAL field-name prints subtotals
  • Yes — TOTAL replaces SUM
  • TOTAL is JCL only

2. On a control report, quantitative fields on LINE are totaled by default unless:

  • SUM limits which fields total
  • TITLE blocks totals
  • WRITE prevents totals
  • GET clears totals

3. CONTROL DEPT causes totals when:

  • DEPT value changes or at end of report
  • Every record regardless of DEPT
  • Only on TITLE 01
  • Only if STOP is coded

4. FINAL on CONTROL refers to:

  • Grand totals at end of report
  • First detail line
  • File OPEN
  • Screen map footer

5. ADD GROSS TO WS-TOTAL in JOB differs from report SUM because:

  • ADD is procedural in activity logic; SUM is declarative in report block
  • They are identical
  • SUM runs only in Library
  • ADD prints pages
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 CONTROL, SUM, LINE totaling (no TOTAL statement)Sources: Broadcom Easytrieve 11.6 SUM Statement, Control Reports, Processing of ReportsApplies to: Easytrieve report totals and control breaks