Fourth Programming Assignment for CIS12

Break Processing

Spring 2001

For this assignment, you need to modify a program that I have written so that it includes break totals.

The output from the current program is:

11/27/00                    WEEKLY PAYROLL REPORT                    PAGE  1   

  CO   RG   DEPT ID #     EMP NAME                  WEEK PAY        BONUS         
                                                                                  
  10   12   03   1111     John Smith               $5,000.00      $500.00         
  10   12   03   1212     Linda Harris             $5,000.00      $500.00         
  10   12   03   1234     Lawrence Adams           $4,000.00      $350.00         
  10   12   24   2123     Susan Anderson           $3,500.00      $250.00         
  10   12   24   2456     David Brooks             $3,500.00      $100.00         
  10   12   24   2678     Jennifer Ames            $6,000.00      $450.00         
  10   15   17   3332     Sara Fox                 $4,000.00         $.00         
  10   15   17   3333     Joseph Costa             $3,000.00      $300.00         
  10   15   17   3567     Allison Jones            $2,500.00      $250.00         
  10   15   27   3678     Ann Warren               $3,400.00      $340.00         
  10   15   27   3789     Lee Sanders              $1,200.00      $120.00         
  20   15   27   4444     Amy Williams             $6,000.00      $600.00         
  20   15   27   4567     Lucy Anders              $3,000.00      $300.00         
  20   15   28   5678     Seth Brown               $4,500.00      $200.00         
  20   15   28   6666     Carol Richards           $3,000.00      $200.00         
  20   15   28   7654     Susan Reynolds           $3,000.00      $400.00         
  20   17   12   8000     James Higgins            $2,340.00      $234.00         
  20   17   12   8123     Stephen Jones            $4,500.00      $200.00         
  20   17   15   8456     Carl Healy               $2,300.00      $120.00         
  20   17   15   9876     Phillip Sousa            $3,000.00      $450.00         
                     FINAL TOTAL:                 $72,740.00    $5,864.00     

In this program, the first column is company, the next column is region and the next column is department. The structure of the organization is that there are multiple companies. Within each company there are multiple regions and within each region there are multiple departments. Therefore, company is the major break number, region is the intermediate break number and department is the minor break number.

Your job is to add the code to the program that will produce break totals.

The program and the data that is read is available at the Web. A copy of the program is also shown in this assignment.

         IDENTIFICATION DIVISION.  
         PROGRAM-ID. MAJBREAK.  
         AUTHOR. GROCER.  
         ENVIRONMENT DIVISION.  
         INPUT-OUTPUT SECTION.  
         FILE-CONTROL.  
         SELECT INPUT-FILE  
             ASSIGN TO "A:\BREAK00.DAT".  
         SELECT PRINT-FILE  
             ASSIGN TO "A:\breakout.dat".  
         DATA DIVISION.  
         FILE SECTION.  
         FD  INPUT-FILE  
             DATA RECORD IS INPUT-REC.  
         01  INPUT-REC.  
             05  COMPANY         PIC XX.  
             05  REGION          PIC XX.  
             05  DEPT            PIC XX.  
             05  EMP-NO          PIC 9(4).  
             05  EMP-NAME        PIC X(20).  
             05  PAY             PIC 9(4)V99.  
             05  BONUS           PIC 9(3)V99.  
         FD  PRINT-FILE  
             DATA RECORD IS PRINTZ.  
         01  PRINTZ.  
             05  FILLER          PIC X.  
             05  COMPANY-PR      PIC XX.  
             05  FILLER          PIC XXX.  
             05  REGION-PR       PIC XX.  
             05  FILLER          PIC XXX.  
             05  DEPT-PR         PIC XX.  
             05  FILLER          PIC XXX.  
             05  EMP-NO-PR       PIC 9(4).  
             05  FILLER          PIC X(5).  
             05  EMP-NAME-PR     PIC X(20).  
             05  FILLER          PIC X(5).  
             05  PAY-PR          PIC $$,$$$.99.  
             05  FILLER          PIC X(6).  
             05  BONUS-PR        PIC $$$$.99.  
             05  FILLER          PIC X(8).  
         WORKING-STORAGE SECTION.  
         01  PROGRAM-INDICATORS.  
             05  MORE-RECS                PIC XXX      VALUE "YES".  
         01  HOLD-AREAS.  
             05  HOLD-COMPANY             PIC XX       VALUE SPACES.  
             05  HOLD-REGION              PIC XX       VALUE SPACES.  
             05  HOLD-DEPT                PIC XX       VALUE SPACES.  
         01  ACCUMULATORS.  
             05  FINAL-PAY-ACC         PIC 9(8)V99     VALUE 0.  
             05  FINAL-BONUS-ACC       PIC 9(7)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(20) 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-PAY-ACC-ML    PIC $$$$,$$$.99.  
             05  FILLER              PIC X(4)  VALUE SPACES.  
             05  MINOR-BONUS-ACC-ML  PIC $$,$$$.99.  
             05  FILLER              PIC X(8)  VALUE SPACES.  
         01  INTER-TOTAL-LINE.  
             05  FILLER              PIC X(20) VALUE SPACES.  
             05  FILLER              PIC X(19)  
                                         VALUE "TOTALS FOR REGION: ".  
             05  REGION-IL           PIC 99    VALUE 0.  
             05  FILLER              PIC X(7)  VALUE SPACES.  
             05  INTER-PAY-ACC-IL    PIC $$$$,$$$.99.  
             05  FILLER              PIC X(3)  VALUE SPACES.  
             05  INTER-BONUS-ACC-IL  PIC $$$,$$$.99.  
             05  FILLER              PIC X(8)  VALUE SPACES.  
         01  MAJOR-TOTAL-LINE.  
             05  FILLER               PIC X(20)   VALUE SPACES.  
             05  FILLER               PIC X(21)  
                                          VALUE "TOTALS FOR COMPANY: ".  
             05  COMPANY-MJL              PIC 99  VALUE 0.  
             05  FILLER               PIC X(3)    VALUE SPACES.  
             05  MAJOR-PAY-ACC-MJL    PIC $$,$$$,$$$.99.  
             05  FILLER               PIC X(2)    VALUE SPACES.  
             05  MAJOR-BONUS-ACC-MJL  PIC $$$$,$$$.99.  
             05  FILLER               PIC X(8)    VALUE SPACES.  
         01  FINAL-TOTAL-LINE.  
             05  FILLER              PIC X(20) VALUE SPACES.  
             05  FILLER              PIC X(13) VALUE "FINAL TOTAL: ".  
             05  FILLER              PIC X(12) VALUE SPACES.  
             05  FINAL-PAY-ACC-FL    PIC $$$,$$$,$$$.99.  
             05  FILLER              PIC X(1)  VALUE SPACES.  
             05  FINAL-BONUS-ACC-FL  PIC $$$$$,$$$.99.  
             05  FILLER              PIC X(8)  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(20) VALUE SPACES.  
             05  FILLER              PIC X(21)  
                           VALUE "WEEKLY PAYROLL 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(2)  VALUE SPACES.  
         01  COLUMN-HDR.  
             05  FILLER              PIC X     VALUE SPACES.  
             05  FILLER              PIC XX    VALUE "CO".  
             05  FILLER              PIC XXX   VALUE SPACES.  
             05  FILLER              PIC XX    VALUE "RG".  
             05  FILLER              PIC XXX   VALUE SPACES.  
             05  FILLER              PIC X(4)  VALUE "DEPT".  
             05  FILLER              PIC X     VALUE SPACES.  
             05  FILLER              PIC X(6)  VALUE "ID #".  
             05  FILLER              PIC X(3)  VALUE SPACES.  
             05  FILLER              PIC X(9)  VALUE "EMP NAME".  
             05  FILLER              PIC X(17) VALUE SPACES.  
             05  FILLER              PIC X(8)  VALUE "WEEK PAY".  
             05  FILLER              PIC X(8)  VALUE SPACES.  
             05  FILLER              PIC X(5)  VALUE "BONUS".  
             05  FILLER              PIC X(3)  VALUE SPACES.  
             05  FILLER              PIC X(5)  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 MO-WS TO MO-HDR.  
             MOVE DA-WS TO DA-HDR.  
             MOVE YR-WS TO YR-HDR.  
         B-100-PROCESS.  
             READ INPUT-FILE  
                AT END  
                   MOVE "NO " TO MORE-RECS.  
             PERFORM B-200-LOOP  
                UNTIL MORE-RECS = "NO ".  
             PERFORM B-340-FINAL-ROUT.  
         B-200-LOOP.  
             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 COMPANY TO COMPANY-PR.  
             MOVE REGION TO REGION-PR.  
             MOVE DEPT TO DEPT-PR.  
             MOVE EMP-NO TO EMP-NO-PR.  
             MOVE EMP-NAME TO EMP-NAME-PR.  
             MOVE PAY TO PAY-PR.  
             MOVE BONUS TO BONUS-PR.  
             WRITE PRINTZ  
                AFTER ADVANCING 1 LINES.  
             ADD 1 TO LINE-CT.  
             ADD PAY TO FINAL-PAY-ACC.  
             ADD BONUS TO FINAL-BONUS-ACC.  
         B-340-FINAL-ROUT.  
             MOVE FINAL-PAY-ACC TO FINAL-PAY-ACC-FL.  
             MOVE FINAL-BONUS-ACC TO FINAL-BONUS-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.