Write per-region totals at end of the daily feed

Cobol · COBOL · intermediate · modification

Adds the end-of-run summary step to REGSUM: after the feed is exhausted, the program sweeps the region table and writes one SUM-FILE record per accumulated region, exactly as the downstream reconciliation job expects.

The summary file is compared against the source system's own per-region totals; a region missing from SUM-FILE shows up as a reconciliation break the next morning.

Requirements

Files touched

--- src/batch/REGSUM.cbl
                END-READ
            END-PERFORM
+           PERFORM 300-WRITE-SUMMARY
            CLOSE TXN-FILE
            CLOSE SUM-FILE
            ADD TXN-AMOUNT TO WS-REG-TOTAL (WS-IX)
            ADD 1 TO WS-REG-COUNT (WS-IX).
+       300-WRITE-SUMMARY.
+           PERFORM VARYING WS-IX FROM 1 BY 1
+                   UNTIL WS-IX = WS-REGION-COUNT
+               MOVE WS-REG-CODE (WS-IX) TO SUM-REGION-CODE
+               MOVE WS-REG-TOTAL (WS-IX) TO SUM-TOTAL
+               MOVE WS-REG-COUNT (WS-IX) TO SUM-TXN-COUNT
+               WRITE SUM-REC
+           END-PERFORM.
 

Review this PR

Cobol practice