Cobol - Barcodes / Items

Seperating a compress .DAT file and output to a table.

Cobol

      *IDENTIFICATION DIVISION
       PROGRAM-ID. ASSIGNMENT-ONE.
       AUTHOR. STEVEN-BARTSCH.
      *******
      *******
      *******

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT F01-ASST1-INPUT ASSIGN TO 'ASST1.DAT'
                                  ORGANIZATION IS LINE SEQUENTIAL.
           SELECT F02-PRINT-FILE  ASSIGN TO 'ASST1.OUT'
                                  ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD F01-ASST1-INPUT
          RECORD CONTAINS 14 CHARACTERS
          DATA RECORD IS F01-ASST1-INPUT.

       01 F01-ASST1-IN.
          05 F01-ITEM-NUMB.
               10 F01-I-A                 PIC 9(1).
               10 F01-I-B                 PIC 9(1).
               10 F01-I-C                 PIC 9(1).
               10 F01-I-D                 PIC 9(1).
               10 F01-I-E                 PIC 9(1).
          05 F01-ASST-QTY                 PIC 9(4).
          05 F01-UNIT-PRICE.
               10 F01-P-A                 PIC 9(1).
               10 F01-P-B                 PIC 9(1).
               10 F01-P-C                 PIC 9(1).
               10 F01-P-D                 PIC 9(1).
               10 F01-P-E                 PIC 9(1).


       FD F02-PRINT-FILE
          RECORD CONTAINS 86 CHARACTERS
          DATA RECORD IS F02-PRINT-LINE-RECORD.
       01 F02-PRINT-LINE-RECORD    PIC X(86).

       WORKING-STORAGE SECTION.
       01 W01-DATA-REMAINS-SWITCH  PIC X(2)        VALUE SPACES.

       01 W02-HEADING-LINE.
          05                       PIC X(19)       VALUE SPACES.
          05                       PIC X(6)        VALUE 'STEVEN'.
          05                       PIC X           VALUE SPACES.
          05                       PIC X(7)        VALUE 'BARTSCH'.
          05                       PIC X           VALUE SPACES.
          05                       PIC X           VALUE '-'.
          05                       PIC X           VALUE SPACES.
          05                       PIC X(12)       VALUE 'COBOL ASST 1'.
          05                       PIC X(38)       VALUE SPACES.

       01 W03-PRINT-NEW-LINE.
          05                       PIC X(86)       VALUE SPACES.

       01 W04-PRINT-TITLE-ONE.
          05                       PIC X(2)        VALUE SPACES.
          05                       PIC X(8)        VALUE 'BARCODED'.
          05                       PIC X(9)        VALUE SPACES.
          05                       PIC X(8)        VALUE 'BARCODED'.
          05                       PIC X(10)       VALUE SPACES.
          05                       PIC X(4)        VALUE 'ITEM'.
          05                       PIC X(8)        VALUE SPACES.
          05                       PIC X(4)        VALUE 'UNIT'.
          05                       PIC X(33)       VALUE SPACES.

       01 W05-PRINT-TITLE-TWO.
          05                       PIC X(11)       VALUE 'ITEM NUMBER'.
          05                       PIC X(7)        VALUE SPACES.
          05                       PIC X(10)       VALUE 'UNIT PRICE'.
          05                       PIC X(8)        VALUE SPACES.
          05                       PIC X(6)        VALUE 'NUMBER'.
          05                       PIC X(7)        VALUE SPACES.
          05                       PIC X(5)        VALUE 'PRICE'.
          05                       PIC X(32)       VALUE SPACES.

       01 W06-RECORDS.
          05 W06-TOTAL-ITEMS          PIC 9(7)     VALUE ZEROS.
          05 W06-BARCODE-ITEM-NUMBER  PIC 9(7)     VALUE ZEROS.
          05 W06-BARCODE-UNIT-PRICE   PIC 9(7)     VALUE ZEROS.
          05 W06-BARCODE-CHECK-ITEM   PIC 9(2).
          05 W06-BARCODE-CHECK-UNIT   PIC 9(2).

       01 W07-PRINT-RECORDS.
          05 W07-PRINT-BARCODE-NUMB   PIC X(5).
          05 W07-PRINT-CHECK-ITEM     PIC X(14).
          05 W07-PRINT-BARCODE-UNIT   PIC X(5).
          05 W07-PRINT-CHECK-UNIT     PIC X(13).
          05 W07-PRINT-ITEM-NUMB      PIC X(12).
          05 W07-PRINT-UNIT-PRICE     PIC X(37).

       01 W08-PRINT-TOTAL-LINE.
          05                          PIC X(20)    VALUE 'TOTAL ITEMS'.
          05 W08-PRINT-TOTAL          PIC X(7)     VALUE SPACES.

       PROCEDURE DIVISION.
           PERFORM 100-OPEN-FILES
           PERFORM 200-PRINT-HEADINGS
           PERFORM 300-PROCESS-RECORDS
               UNTIL W01-DATA-REMAINS-SWITCH = 'NO'
           PERFORM 400-PRINT-TOTALS
           PERFORM 500-CLOSE-FILES
           STOP RUN.

       100-OPEN-FILES.
           OPEN INPUT  F01-ASST1-INPUT
                OUTPUT F02-PRINT-FILE
           .
       200-PRINT-HEADINGS.
           MOVE W02-HEADING-LINE TO F02-PRINT-LINE-RECORD
           WRITE F02-PRINT-LINE-RECORD
           MOVE W03-PRINT-NEW-LINE TO F02-PRINT-LINE-RECORD
           WRITE F02-PRINT-LINE-RECORD
           MOVE W04-PRINT-TITLE-ONE TO F02-PRINT-LINE-RECORD
           WRITE F02-PRINT-LINE-RECORD
           MOVE W05-PRINT-TITLE-TWO TO F02-PRINT-LINE-RECORD
           WRITE F02-PRINT-LINE-RECORD
           .
       300-PROCESS-RECORDS.
           READ F01-ASST1-INPUT
               PERFORM 310-DO-CALCULATIONS
               MOVE F01-ITEM-NUMB TO W07-PRINT-ITEM-NUMB
               MOVE F01-UNIT-PRICE TO W07-PRINT-UNIT-PRICE
               MOVE F01-ITEM-NUMB TO W07-PRINT-BARCODE-NUMB
               MOVE W06-BARCODE-CHECK-ITEM TO W07-PRINT-CHECK-ITEM
               MOVE F01-UNIT-PRICE TO W07-PRINT-BARCODE-UNIT
               MOVE W06-BARCODE-CHECK-ITEM TO W07-PRINT-CHECK-UNIT
               MOVE W07-PRINT-RECORDS TO F02-PRINT-LINE-RECORD
               AT END MOVE 'NO' TO W01-DATA-REMAINS-SWITCH
           END-READ
           WRITE F02-PRINT-LINE-RECORD
           .
       310-DO-CALCULATIONS.
           COMPUTE W06-BARCODE-CHECK-ITEM
           ROUNDED = (F01-I-A + F01-I-B + F01-I-C + F01-I-D +
           F01-I-A)/5*3
           END-COMPUTE

           COMPUTE W06-BARCODE-CHECK-UNIT
           ROUNDED = (F01-P-A + F01-P-B + F01-P-C + F01-P-D +
           F01-P-E)/5*3
           END-COMPUTE

           COMPUTE W06-TOTAL-ITEMS = W06-TOTAL-ITEMS + 1
           END-COMPUTE
           .
       400-PRINT-TOTALS.
           MOVE W06-TOTAL-ITEMS TO W08-PRINT-TOTAL
           MOVE W08-PRINT-TOTAL-LINE TO F02-PRINT-LINE-RECORD
           WRITE F02-PRINT-LINE-RECORD
           .
       500-CLOSE-FILES.
           CLOSE F01-ASST1-INPUT
           CLOSE F02-PRINT-FILE
           .

DAT Input File

11080105000100
12400120001400
13050001000200
14450020001350
23010010000200
31054100000050
05100006000213
02187090600045
95678002000300
10234001000024

OUT Output File

                   STEVEN BARTSCH - COBOL ASST 1

  BARCODED         BARCODED          ITEM        UNIT
ITEM NUMBER       UNIT PRICE        NUMBER       PRICE
1108007            0010007           11080       00100
1240005            0140005           12400       01400
1305006            0020006           13050       00200
1445009            0135009           14450       01350
2301005            0020005           23010       00200
3105407            0005007           31054       00050
0510004            0021304           05100       00213
0218707            0004507           02187       00045
9567822            0030022           95678       00300
1023404            0002404           10234       00024
TOTAL ITEMS         0000010