>>SOURCE FORMAT IS FREE *> cobol-group-items.cob — a customer record as a group item *> Dialect: GnuCOBOL 3.x, free format *> Status : desk-checked against the GnuCOBOL 3.2 Programmer's Guide; *> compiled and run with GnuCOBOL 3.2 on 2026-10-29 *> Inputs : none *> Outputs: DISPLAY lines on the console *> Build : cobc -x cobol-group-items.cob *> Run : ./cobol-group-items *> (Windows: cobol-group-items.exe) IDENTIFICATION DIVISION. PROGRAM-ID. GROUP-ITEMS. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. *> One 80-byte record. The 01 level is the group; every item with a *> PICTURE is elementary; Cust-Address and Last-Payment-Date are *> groups inside the group. 01 Customer-Record. 05 Cust-Id PIC 9(6) VALUE 104233. 05 Cust-Name PIC X(20) VALUE "MARGARET OKONKWO". 05 Cust-Address. 10 Addr-Street PIC X(18) VALUE "17 HARBOUR ROW". 10 Addr-City PIC X(10) VALUE "GALWAY". 10 Addr-Postcode PIC X(7) VALUE "H91X2Y3". 05 Cust-Balance PIC S9(7)V99 SIGN IS LEADING SEPARATE VALUE -1250.75. 05 Cust-Status PIC X VALUE "A". 88 Cust-Active VALUE "A". 88 Cust-Closed VALUE "C". 05 Last-Payment-Date. 10 LPD-Year PIC 9(4) VALUE 2026. 10 LPD-Month PIC 9(2) VALUE 8. 10 LPD-Day PIC 9(2) VALUE 29. *> Level 77 items stand alone; they can never have subordinates. 77 WS-Record-Length PIC 9(3). 77 WS-Balance-Out PIC -(7)9.99. PROCEDURE DIVISION. Main-Paragraph. MOVE FUNCTION LENGTH(Customer-Record) TO WS-Record-Length DISPLAY "Record length : " WS-Record-Length DISPLAY "Raw record : [" Customer-Record "]" DISPLAY "Name : [" Cust-Name "]" DISPLAY "City : [" Addr-City "]" DISPLAY "Balance raw : " Cust-Balance MOVE Cust-Balance TO WS-Balance-Out DISPLAY "Balance edited: " WS-Balance-Out DISPLAY "Paid on : " LPD-Year "-" LPD-Month "-" LPD-Day IF Cust-Active DISPLAY "Status : active" END-IF *> Elementary moves: each receiving field pads, aligns or converts *> according to its own PICTURE. MOVE "DUBLIN" TO Addr-City MOVE 9 TO LPD-Month MOVE 1 TO LPD-Day ADD 100 TO Cust-Balance SET Cust-Closed TO TRUE DISPLAY "After moves : [" Customer-Record "]" *> A group move copies bytes left to right and converts nothing, *> so text lands in the numeric fields underneath. MOVE "2026-09-05" TO Last-Payment-Date DISPLAY "Group move : [" Last-Payment-Date "] year=" LPD-Year MOVE SPACES TO Cust-Address DISPLAY "Cleared addr : [" Cust-Address "]" STOP RUN.