Stakeholders ask for two numbers on every operational report: detail lines they can audit and totals they can reconcile to the general ledger. Easytrieve separates how rows are selected—PRINT in JOB logic—from how amounts accumulate—CONTROL, SUM, and quantitative fields on LINE inside the REPORT block. When you declare GROSS as P 7 2 on LINE, the report writer treats it as quantitative and, on control reports, automatically sums it at each break and at FINAL unless SUM narrows the list. FINAL is the grand total pass after the last detail record: department subtotals may have printed already, but FINAL adds company-wide gross pay on the closing total line. REPORT SUMMARY flips the emphasis— only totals print, no detail—ideal for executive rollups. Beginners hand-add with ADD in JOB and duplicate what SUM already provides, then wonder why printed subtotals disagree with procedural counters after control breaks reset internal accumulators. This page explains automatic versus explicit totaling, SUM grammar, FINAL and SUMCTL formatting, TALLY concepts, SUMMARY reports, and reconciling procedural ADD totals with declarative report totals.
12345REPORT PAY-RPT LINESIZE 132 TITLE 01 'PAYROLL TOTALS' LINE 01 DEPT EMPNO GROSS DEDUCTIONS NET-PAY CONTROL DEPT SUM GROSS DEDUCTIONS NET-PAY
SUM field-name lists one or more quantitative fields to accumulate. Valid only in control reports with CONTROL statement present. When SUM is omitted, every quantitative field on LINE auto-totals—a convenience until DEDUCTIONS should print on detail but not roll into department subtotals; then SUM lists only GROSS and NET-PAY. SUM fields need not appear on LINE—accumulate a hidden tax bucket and print it only on total lines via SUMCTL and LINE layout on break rows.
| Source | Behavior | Typical use |
|---|---|---|
| LINE quantitative fields | Auto-sum at breaks if no SUM | Simple reports—total every amount column |
| SUM statement | Only listed fields accumulate | Selective totaling, hidden sum fields |
| ADD in JOB body | Manual working storage counters | Limits, audit checks, non-report outputs |
| FINAL break | Grand totals after all groups | Company-wide totals on last lines |
Numeric fields need decimal positions in DEFINE—even P 5 0—to be quantitative and participate in SUM and auto-totaling. P 5 without decimals may be non-quantitative and print without accumulation. Currency amounts use P w d with implied decimals; verify data-types decimal tutorial when totals show zero unexpectedly. MASK on LINE affects print format, not accumulation eligibility.
CONTROL FINAL options apply to end-of-report break equivalent to highest-level closeout. FINAL NEWPAGE starts grand total section on fresh page. FINAL NOPRINT suppresses grand total line printing while lower breaks may still print. BEFORE-BREAK and AFTER-BREAK run for FINAL level—compute company-wide percentage of gross to budget in BEFORE-BREAK when LEVEL indicates final pass. Grand totals include all records that PRINT selected into the report, not entire input file if JOB filtered records.
12345REPORT EXEC-SUMMARY LINESIZE 80 SUMMARY TITLE 01 'EXECUTIVE PAYROLL SUMMARY' LINE 01 REGION DEPT GROSS CONTROL REGION DEPT SUM GROSS
SUMMARY inhibits detail LINE output. Only control total lines print—one row per break level per group closure. Pair with CONTROL hierarchy for region and department rollups without employee numbers on paper. Distinct from SUM statement: SUMMARY is REPORT parameter; SUM lists fields.
SUMCTL on REPORT controls printing control field values and detail copies on total lines. ALL prints control values on every total line level. DTLCOPY prints detail field contents on level-1 breaks only—show last employee name on zip subtotal row, for example. HIAR, NONE, and TAG modes adjust hierarchical annotations. Place control fields first on LINE so subtotal rows show DEPT beside summed GROSS without custom BEFORE-BREAK MOVE unless formatting demands more.
Control report summary file documentation describes TALLY as record count per control group in summary file records—useful for reconciliation interfaces. On printed reports, display counts via report writer functions, working storage incremented in REPORT-INPUT, or fields exposed through BEFORE-BREAK from internal counters depending on release. Do not confuse TALLY with quantitative SUM of amounts—counts versus dollars serve different audit checks.
Pattern: ADD GROSS TO WS-RUN-TOTAL in JOB for validation DISPLAY at FINISH; SUM GROSS on REPORT for printed subtotals. Both should match when every printed record added once. Filters—IF before PRINT, REPORT-INPUT SELECT—cause mismatch if ADD runs on different condition than PRINT. Single source of truth: prefer SUM for printed totals; use ADD only when totals feed non-report outputs or cross-check SUM via DISPLAY in FINISH procedure comparing WS-RUN-TOTAL to report-accessible accumulators if exposed.
Totals are the answer at the bottom of the math worksheet. SUM tells the calculator which numbers to add. Every time the department changes, the calculator prints the department answer (subtotal). At the very end it prints the whole-school answer (FINAL). SUMMARY is a worksheet with only the answers, no middle steps. ADD in JOB is you adding on a side scrap of paper—the printed worksheet only matches if you added the same rows the teacher printed.
1. On control reports, quantitative LINE fields are totaled by default unless:
2. FINAL on CONTROL refers to:
3. SUM GROSS NET-PAY means:
4. REPORT SUMMARY produces:
5. ADD AMOUNT TO WS-TOTAL in JOB differs from SUM because: