IDENTIFICATION DIVISION. PROGRAM-ID. MINBREAK. AUTHOR. GROCER. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO "C:\COBOLS\CIS51\MAJOR.DAT". SELECT PRINT-FILE ASSIGN TO "C:\COBOLS\CIS51\MAJORCC.DAT". DATA DIVISION. FILE SECTION. FD INPUT-FILE DATA RECORD IS INPUT-REC. 01 INPUT-REC. 05 FILLER PIC XXXX. 05 DEPT PIC XX. 05 ITEM-NO PIC 9(4). 05 ITEM-NAME PIC X(20). 05 ON-HAND PIC 9(3). 05 PRICE PIC 9(3)V99. FD PRINT-FILE DATA RECORD IS PRINTZ. 01 PRINTZ. 05 FILLER PIC X. 05 DEPT-PR PIC XX. 05 FILLER PIC XXX. 05 ITEM-NO-PR PIC 9(4). 05 FILLER PIC X(5). 05 ITEM-NAME-PR PIC X(20). 05 FILLER PIC X(5). 05 ON-HAND-PR PIC ZZ9. 05 FILLER PIC X(4). 05 PRICE-PR PIC $$$9.99. 05 FILLER PIC X(5). 05 INV-VALUE-PR PIC $$$,$$9.99. 05 FILLER PIC X(11). WORKING-STORAGE SECTION. 01 PROGRAM-INDICATORS. 05 MORE-RECS PIC XXX VALUE "YES". 01 HOLD-AREAS. 05 HOLD-DEPT-WS PIC XX VALUE SPACES. 01 WORK-AREAS. 05 INV-VALUE-WS PIC 9(5)V99 VALUE 0. 01 ACCUMULATORS. 05 MINOR-ONHAND-ACC PIC 9(4) VALUE 0. 05 FINAL-ONHAND-ACC PIC 9(6) VALUE 0. 05 MINOR-VALUE-ACC PIC 9(6)V99 VALUE 0. 05 FINAL-VALUE-ACC PIC 9(8)V99 VALUE 0. 01 PAGE-CONTROL. 05 PAGE-NO PIC 99 VALUE 1. 05 LINE-CT PIC 99 VALUE 0. 01 DATE-WS. 05 YR-WS PIC 99 VALUE 0. 05 MO-WS PIC 99 VALUE 0. 05 DA-WS PIC 99 VALUE 0. 01 MINOR-TOTAL-LINE. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(17) VALUE "TOTALS FOR DEPT: ". 05 DEPT-ML PIC 99 VALUE 0. 05 FILLER PIC X(9) VALUE SPACES. 05 MINOR-ONHAND-ACC-ML PIC Z,ZZ9. 05 FILLER PIC X(15) VALUE SPACES. 05 MINOR-VALUE-ACC-ML PIC $$$$,$$9.99. 05 FILLER PIC X(11) VALUE SPACES. 01 FINAL-TOTAL-LINE. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(13) VALUE "FINAL TOTAL: ". 05 FILLER PIC X(13) VALUE SPACES. 05 FINAL-ONHAND-ACC-FL PIC ZZZ,ZZ9. 05 FILLER PIC X(12) VALUE SPACES. 05 FINAL-VALUE-ACC-FL PIC $$$,$$$,$$9.99. 05 FILLER PIC X(11) VALUE SPACES. 01 PAGE-HDR. 05 FILLER PIC XX VALUE SPACES. 05 DATE-HDR. 10 MO-HDR PIC 99. 10 FILLER PIC X VALUE "/". 10 DA-HDR PIC 99. 10 FILLER PIC X VALUE "/". 10 YR-HDR PIC 99. 05 FILLER PIC X(22) VALUE SPACES. 05 FILLER PIC X(16) VALUE "INVENTORY REPORT". 05 FILLER PIC X(20) VALUE SPACES. 05 FILLER PIC X(5) VALUE "PAGE ". 05 PAGE-NO-HDR PIC Z9. 05 FILLER PIC X(5) VALUE SPACES. 01 COLUMN-HDR. 05 FILLER PIC X VALUE SPACES. 05 FILLER PIC X(4) VALUE "DEPT". 05 FILLER PIC X VALUE SPACES. 05 FILLER PIC X(6) VALUE "ITEM #". 05 FILLER PIC X(3) VALUE SPACES. 05 FILLER PIC X(9) VALUE "ITEM NAME". 05 FILLER PIC X(13) VALUE SPACES. 05 FILLER PIC X(7) VALUE "ON HAND". 05 FILLER PIC X(4) VALUE SPACES. 05 FILLER PIC X(7) VALUE "PRICE". 05 FILLER PIC X(3) VALUE SPACES. 05 FILLER PIC X(11) VALUE "INVEN VALUE". 05 FILLER PIC X(11) VALUE SPACES. PROCEDURE DIVISION. MAINLINE. PERFORM A-100-INITIALIZE. PERFORM B-100-PROCESS. PERFORM C-100-WRAPUP. STOP RUN. A-100-INITIALIZE. OPEN INPUT INPUT-FILE OUTPUT PRINT-FILE. ACCEPT DATE-WS FROM DATE. MOVE YR-WS TO YR-HDR. MOVE MO-WS TO MO-HDR. MOVE DA-WS TO DA-HDR. B-100-PROCESS. READ INPUT-FILE AT END MOVE "NO " TO MORE-RECS. MOVE DEPT TO HOLD-DEPT-WS. PERFORM B-200-LOOP UNTIL MORE-RECS = "NO ". *Call the routine to do the minor total routine in the *program tocall1. Note that you need to pass the accumulators, *the minor total line and the dept hold area. PERFORM B-310-MINOR-ROUT. PERFORM B-320-FINAL-ROUT. B-200-LOOP. IF DEPT NOT = HOLD-DEPT-WS *Call the routine to do the minor total routine in the *program tocall1. Note that you need to pass the accumulators, *the minor total line and the dept hold area. PERFORM B-310-MINOR-ROUT PERFORM U-000-BLANK-LINE. PERFORM B-300-DETAIL. READ INPUT-FILE AT END MOVE "NO " TO MORE-RECS. B-300-DETAIL. IF LINE-CT > 50 OR PAGE-NO = 1 PERFORM B-400-HDR-ROUT. MOVE SPACES TO PRINTZ. MOVE DEPT TO DEPT-PR. MOVE ITEM-NO TO ITEM-NO-PR. MOVE ITEM-NAME TO ITEM-NAME-PR. MOVE ON-HAND TO ON-HAND-PR. MOVE PRICE TO PRICE-PR. MULTIPLY ON-HAND BY PRICE GIVING INV-VALUE-WS. MOVE INV-VALUE-WS TO INV-VALUE-PR. WRITE PRINTZ AFTER ADVANCING 1 LINES. ADD 1 TO LINE-CT. ADD ON-HAND TO MINOR-ONHAND-ACC. ADD ON-HAND TO FINAL-ONHAND-ACC. ADD INV-VALUE-WS TO MINOR-VALUE-ACC. ADD INV-VALUE-WS TO FINAL-VALUE-ACC. B-310-MINOR-ROUT. * MOVE HOLD-DEPT-WS TO DEPT-ML. * MOVE MINOR-ONHAND-ACC TO MINOR-ONHAND-ACC-ML. * MOVE MINOR-VALUE-ACC TO MINOR-VALUE-ACC-ML. WRITE PRINTZ FROM MINOR-TOTAL-LINE AFTER ADVANCING 2 LINES. MOVE DEPT TO HOLD-DEPT-WS. MOVE 0 TO MINOR-ONHAND-ACC. MOVE 0 TO MINOR-VALUE-ACC. ADD 2 TO LINE-CT. B-320-FINAL-ROUT. MOVE FINAL-ONHAND-ACC TO FINAL-ONHAND-ACC-FL. MOVE FINAL-VALUE-ACC TO FINAL-VALUE-ACC-FL. WRITE PRINTZ FROM FINAL-TOTAL-LINE AFTER ADVANCING 1 LINES. B-400-HDR-ROUT. MOVE PAGE-NO TO PAGE-NO-HDR. WRITE PRINTZ FROM PAGE-HDR AFTER ADVANCING PAGE. WRITE PRINTZ FROM COLUMN-HDR AFTER ADVANCING 2 LINES. PERFORM U-000-BLANK-LINE. ADD 1 TO PAGE-NO. MOVE 4 TO LINE-CT. U-000-BLANK-LINE. MOVE SPACES TO PRINTZ. WRITE PRINTZ AFTER ADVANCING 1 LINES. ADD 1 TO LINE-CT. C-100-WRAPUP. CLOSE INPUT-FILE PRINT-FILE.