Last Programming Assignment for CIS12
Break Processing
Fall 2001
This assignment involves modifying a program that I have written - the program is named
BREAKASG.CBL. It reads a data file called break01.dat.
This assignment has two parts: The first part involves breaks and the second part involves
tables.
- Breaks Part: You need to modify a program that I have written so that it includes break
totals.
- Tables Part: You need to modify the same program so it prints the names of the department and the names must be gotten from a table using a subscript.
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 01 1111 John Smith $5,000.00 $500.00
10 12 01 1212 Linda Harris $5,000.00 $500.00
10 12 01 1234 Lawrence Adams $4,000.00 $350.00
10 12 02 2123 Susan Anderson $3,500.00 $250.00
10 12 02 2456 David Brooks $3,500.00 $100.00
10 12 02 2678 Jennifer Ames $6,000.00 $450.00
10 15 03 3332 Sara Fox $4,000.00 $.00
10 15 03 3333 Joseph Costa $3,000.00 $300.00
10 15 03 3567 Allison Jones $2,500.00 $250.00
10 15 04 3678 Ann Warren $3,400.00 $340.00
10 15 04 3789 Lee Sanders $1,200.00 $120.00
20 15 04 4444 Amy Williams $6,000.00 $600.00
20 15 04 4567 Lucy Anders $3,000.00 $300.00
20 15 05 5678 Seth Brown $4,500.00 $200.00
20 15 05 6666 Carol Richards $3,000.00 $200.00
20 15 05 7654 Susan Reynolds $3,000.00 $400.00
20 17 02 8000 James Higgins $2,340.00 $234.00
20 17 02 8123 Stephen Jones $4,500.00 $200.00
20 17 04 8456 Carl Healy $2,300.00 $120.00
20 17 04 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 and the
department name from a table.
- If you only do minor breaks on department your maximum grade is C.
- If you only do major breaks on company, intermediate breaks on region and minor breaks
on department, your maximum grade is B.
- If you include the department name from a table in addition to the minor, intermediate
and major break processing you can earn an A or A+ in the program.
- For extra credit, do group indicating!
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:\BREAK01.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.
The data file (BREAK01.DAT) is shown below:
1012011111John Smith 50000050000
1012011212Linda Harris 50000050000
1012011234Lawrence Adams 40000035000
1012022123Susan Anderson 35000025000
1012022456David Brooks 35000010000
1012022678Jennifer Ames 60000045000
1015033332Sara Fox 40000000000
1015033333Joseph Costa 30000030000
1015033567Allison Jones 25000025000
1015043678Ann Warren 34000034000
1015043789Lee Sanders 12000012000
2015044444Amy Williams 60000060000
2015044567Lucy Anders 30000030000
2015055678Seth Brown 45000020000
2015056666Carol Richards 30000020000
2015057654Susan Reynolds 30000040000
2017028000James Higgins 23400023400
2017028123Stephen Jones 45000020000
2017048456Carl Healy 23000012000
2017049876Phillip Sousa 30000045000
The Department code stands for the following department names:
DEPT 01 is BOOKS
DEPT 02 is TOYS
DEPT 03 is COMPUTERS
DEPT 04 is GIFTS
DEPT 05 is TRAVEL
Due the last day of classes!