IDENTIFICATION DIVISION.
       PROGRAM-ID. MINBREAK.
       AUTHOR. GROCER.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT INPUT-FILE
           ASSIGN TO "C:\PCOBWIN\CIS12FST\MAJOR.DAT".
       SELECT PRINT-FILE
           ASSIGN TO PRINTER.
       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 ".
           PERFORM B-310-MINOR-ROUT.
           PERFORM B-320-FINAL-ROUT.
       B-200-LOOP.
           IF DEPT NOT = HOLD-DEPT-WS
               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.
      *
      *Input data:
      *
      *0110121234HOE                 01201899
      *0110121235RAKE                02501595
      *0110151111TROWEL              02000599
      *0110151112HAND HOE            01400799
      *0120171000LILY                05000199
      *0120171001TULIP               07500299
      *0121223000PANSY               11200599
      *0121223001PETUNIA             10000499
      *0230245555DOGWOOD             01010099
      *0230245556CHERRY              01012000
      *0240276789WHITE PINE          00513500
      *0240276790BLACK PINE          01020000
      *0250553456MAPLE               00807500
      *0250553457OAK                 00909900
      *
      *Output report:
      *
      *  04/11/99                      INVENTORY REPORT                    PAGE  1
      *
      * DEPT ITEM #   ITEM NAME             ON HAND    PRICE     INVEN VALUE
      *
      * 12   1234     HOE                       12     $18.99        $227.88
      * 12   1235     RAKE                      25     $15.95        $398.75
      *
      *          TOTALS FOR DEPT: 12            37                   $626.63
      *
      * 15   1111     TROWEL                    20      $5.99        $119.80
      * 15   1112     HAND HOE                  14      $7.99        $111.86
      *
      *          TOTALS FOR DEPT: 15            34                   $231.66
      *
      * 17   1000     LILY                      50      $1.99         $99.50
      * 17   1001     TULIP                     75      $2.99        $224.25
      *
      *          TOTALS FOR DEPT: 17           125                   $323.75
      *
      * 22   3000     PANSY                    112      $5.99        $670.88
      * 22   3001     PETUNIA                  100      $4.99        $499.00
      *
      *          TOTALS FOR DEPT: 22           212                 $1,169.88
      *
      * 24   5555     DOGWOOD                   10    $100.99      $1,009.90
      * 24   5556     CHERRY                    10    $120.00      $1,200.00
      *
      *          TOTALS FOR DEPT: 24            20                 $2,209.90
      *
      * 27   6789     WHITE PINE                 5    $135.00        $675.00
      * 27   6790     BLACK PINE                10    $200.00      $2,000.00
      *
      *          TOTALS FOR DEPT: 27            15                 $2,675.00
      *
      * 55   3456     MAPLE                      8     $75.00        $600.00
      * 55   3457     OAK                        9     $99.00        $891.00
      *
      *          TOTALS FOR DEPT: 55            17                 $1,491.00
      *          FINAL TOTAL:                  460                 $8,727.82