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.
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.
| Statement | Role in totaling |
|---|---|
| REPORT | Declares control report (default) or SUMMARY |
| SEQUENCE | Orders input major-to-minor for breaks |
| CONTROL | Names break fields; triggers subtotal lines |
| LINE | Lists detail fields; quantitative ones total by default |
| SUM | Optional—limits which fields are totaled |
12345REPORT 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.
123456REPORT 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.
| Option | Effect on totals |
|---|---|
| NEWPAGE | Page break after printing break totals (or before FINAL totals) |
| NOPRINT | Accumulate but do not print subtotal line for that field level |
| RENUM | Page break and restart page numbering at 1 |
| FINAL NOPRINT | Suppress 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 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.
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.
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.
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.
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.
1. Is TOTAL a standalone report statement in Easytrieve 11.6?
2. On a control report, quantitative fields on LINE are totaled by default unless:
3. CONTROL DEPT causes totals when:
4. FINAL on CONTROL refers to:
5. ADD GROSS TO WS-TOTAL in JOB differs from report SUM because: