>>SOURCE FORMAT IS FREE *> cobol-copybook-list.cob - ACCT-LIST, the second of *> three programs sharing one record layout: list this *> month's account master and total the open balances *> Dialect: GnuCOBOL 3.x, free format *> Status : desk-checked against the GnuCOBOL Programmer's Guide (3.2 *> COPY, 10.1.4 Locating Copybooks); compiled and run with *> GnuCOBOL 3.2 on 2026-10-29 *> Inputs : acct-master-new.dat, written by ACCT-POST (LINE SEQUENTIAL, *> 39 bytes per record) *> code/cobol-copybook-copy-replacing.cpy (the layout, used *> exactly as written, with no renaming) *> Outputs: DISPLAY lines only *> Build : cobc -x -I code -o acct-list code/cobol-copybook-list.cob *> Run : ./acct-list (after ./acct-post, from the same folder) IDENTIFICATION DIVISION. PROGRAM-ID. ACCT-LIST. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT Account-File ASSIGN TO "acct-master-new.dat" ORGANIZATION IS LINE SEQUENTIAL FILE STATUS IS WS-Acct-FS. DATA DIVISION. FILE SECTION. FD Account-File. COPY "cobol-copybook-copy-replacing.cpy". WORKING-STORAGE SECTION. 77 WS-Acct-FS PIC XX. 01 WS-Flags. 05 WS-EOF-Flag PIC X VALUE "N". 88 End-Of-File VALUE "Y". 77 WS-Open-Count PIC 9(5) VALUE 0. 77 WS-Closed-Count PIC 9(5) VALUE 0. 77 WS-Open-Total PIC 9(9)V99 VALUE 0. 77 WS-Status-Word PIC X(6). 77 WS-Show-Count PIC ZZ,ZZ9. 77 WS-Show-Money PIC Z,ZZZ,ZZ9.99. PROCEDURE DIVISION. Main-Paragraph. OPEN INPUT Account-File IF WS-Acct-FS NOT = "00" DISPLAY "Cannot open acct-master-new.dat, status " WS-Acct-FS DISPLAY "Run acct-post first, from the same folder." STOP RUN END-IF DISPLAY "ID NAME BR STATUS BALANCE" PERFORM Read-Account PERFORM UNTIL End-Of-File PERFORM List-One-Account PERFORM Read-Account END-PERFORM CLOSE Account-File MOVE WS-Open-Count TO WS-Show-Count MOVE WS-Open-Total TO WS-Show-Money DISPLAY "Open accounts " WS-Show-Count " balance " WS-Show-Money MOVE WS-Closed-Count TO WS-Show-Count DISPLAY "Closed accounts " WS-Show-Count STOP RUN. Read-Account. READ Account-File AT END SET End-Of-File TO TRUE END-READ IF WS-Acct-FS NOT = "00" AND WS-Acct-FS NOT = "10" DISPLAY "Account file read failed, status " WS-Acct-FS STOP RUN END-IF. *> The 88-level names from the copybook, Acct-Open and Acct-Closed, *> arrive with the record; this program never tests the letter itself. List-One-Account. IF Acct-Open MOVE "open" TO WS-Status-Word ADD 1 TO WS-Open-Count ADD Acct-Balance TO WS-Open-Total ELSE IF Acct-Closed MOVE "closed" TO WS-Status-Word ADD 1 TO WS-Closed-Count ELSE MOVE "other" TO WS-Status-Word END-IF END-IF MOVE Acct-Balance TO WS-Show-Money DISPLAY Acct-Id " " Acct-Name " " Acct-Branch " " WS-Status-Word " " WS-Show-Money.