Sales reporting is among the most visible Easytrieve workloads in retail and wholesale organizations. Store managers expect a daily listing of transactions by register; regional directors expect district rollups by the 6 a.m. deadline; finance expects net sales to tie to general ledger posting from the same business date. Easytrieve reads consolidated transaction extracts—often millions of rows per night—and produces formatted reports with control breaks, category decodes, and hash totals operators sign off before email distribution. This tutorial explains typical sales file layouts, how to calculate extended amounts and discounts, store and region subtotals, daily versus monthly calendar logic, comparison to prior periods, exception handling for bad store codes, and JCL patterns that fit the retail batch window.
Upstream consolidation jobs merge register tapes, e-commerce orders, and returns into one sequential extract. Easytrieve FILE definition must match copybook picture exactly—especially signed quantity on returns and implied decimal on currency fields.
12345678910FILE SALETRN STORE-ID 5 NUM REG-NO 3 NUM TRAN-DATE 8 NUM SKU-NO 12 A QTY-SOLD 7.0 UNIT-PRICE 7.2 DISC-AMT 7.2 NET-AMT 9.2 DEPT-CODE 3 NUM
STORE-ID identifies physical or virtual store. REG-NO is register or lane number for detail audit. TRAN-DATE is CCYYMMDD or shop-specific date format—filter consistently in IF statements. QTY-SOLD may be negative on returns. NET-AMT might be calculated upstream or in Easytrieve as QTY-SOLD times UNIT-PRICE minus DISC-AMT; pick one authoritative source to avoid double subtraction.
123456789101112JOB INPUT SALETRN IF TRAN-DATE NE W-RUN-DATE GOTO JOB END-IF EXT-AMT = QTY-SOLD * UNIT-PRICE NET-LINE = EXT-AMT - DISC-AMT ADD NET-LINE TO W-TOTAL-NET ADD 1 TO W-TRAN-CNT SEARCH STORETAB WITH STORE-ID GIVING STORE-NAME IF NOT STORETAB PERFORM LOG-STORE-EXCEPTION END-IF
W-RUN-DATE comes from PARM, system variable, or control file. GOTO JOB skips records outside the reporting day when extract carries multiple dates. W-TOTAL-NET feeds TITLE trailer for finance tie-out. STORETAB TABLE decodes store id to printable name on detail and break lines.
| Report | Audience | Typical break level |
|---|---|---|
| Daily store register listing | Store manager | Store, then register |
| District sales summary | Regional director | District code |
| Department performance | Merchandising | Department code |
| SKU top sellers | Buying team | SKU with sort by amount descending |
| Exception — unknown SKU or store | Master data team | None — flat exception list |
SORT SALETRN by DISTRICT-CODE, STORE-ID before Easytrieve when district is not on every transaction row—often merged from store master in upstream job. REPORT defines BREAK DISTRICT-CODE with AFTER-BREAK printing district net sales and transaction count. Nested break on STORE-ID within district appears on detailed district reports; summary-only jobs break at district alone.
1234BREAK DISTRICT-CODE AFTER-BREAK PRINT DISTRICT-SUMMARY-LINE W-DIST-NET = ZERO W-DIST-CNT = ZERO
Accumulators W-DIST-NET increment inside JOB for each transaction in the current district group. AFTER-BREAK resets them when district changes. Grand totals accumulate in separate W-GRAND-NET fields updated on every record regardless of break.
Filter single TRAN-DATE equal to business date. Run after POS close—often 2 a.m. to 5 a.m. Tight window demands efficient SORT and minimal TABLE lookups. Title lines show Daily Sales Report and formatted date mask.
Filter TRAN-DATE between W-MONTH-START and W-MONTH-END inclusive. May include adjustment transactions posted on last day of month with special TRAN-TYPE code. Finance expects monthly report net to match GL revenue account for the period—document whether report uses transaction date or posting date when they differ.
DEPT-CODE on transaction ties to merchandising hierarchy. SEARCH DEPTTAB WITH DEPT-CODE GIVING DEPT-NAME for readable columns. Category rollups may map many SKUs to class through ITEMTAB TABLE keyed by SKU-NO returning CLASS-CODE then second SEARCH on CLASSTAB. Chain lookups in DECODE-SALES-FIELDS. PROC keep JOB readable.
Negative QTY-SOLD or TRAN-TYPE codes V and R identify returns and voids. Policy decides whether returns appear on same report as sales or separate Returns Register. IF TRAN-TYPE EQ R route to PERFORM PROCESS-RETURN accumulating W-RETURN-TOT separately from W-SALES-TOT so executives see gross versus net clearly.
Year-over-year district report reads merged file with CURR-AMT and PRIOR-AMT per store or computes PRIOR from second input FILE with MATCH on STORE-ID in advanced designs. VARIANCE equals CURR minus PRIOR; VAR-PCT equals variance divided by PRIOR with zero-divide guard in IF PRIOR NE ZERO. These reports support budgeting meetings; parallel-run against spreadsheet before first production month-end.
1234567//DAYSALES EXEC PGM=EZTPA00,REGION=0M //SYSPRINT DD SYSOUT=* //SYSIN DD DSN=RTL.LIB(EZTDAYSL),DISP=SHR //SALETRN DD DSN=RTL.SALES.DAILY(+1),DISP=SHR //STORETAB DD DSN=RTL.STORE.MASTER,DISP=SHR //RPTOUT DD SYSOUT=(1,INTRDR) //EXCEPT DD DSN=RTL.SALES.EXCEPT(+1),DISP=(,CATLG,DELETE)
High-volume chains process tens of millions of transactions nightly. Presort extracts in dedicated SORT step with sufficient workspace. Merge store master before Easytrieve to avoid per-row SEARCH on large STORETAB. Split by region into parallel jobs when single run exceeds window; combine control totals in downstream control job.
Sales reporting is like counting every lemonade stand sale at the end of the day. Each receipt is a line. Easytrieve adds up how much each stand sold, then how much each neighborhood sold, then the whole city. If a receipt has a stand number nobody recognizes, it goes on a fix-this list instead of the main total so the mayor is not confused.
1. Sales reporting Easytrieve jobs most often read:
2. Regional sales subtotals typically use:
3. Extended sales amount is usually calculated as:
4. Daily versus monthly sales reports differ mainly in:
5. Unknown store code on a transaction should: