I have to produce the following report:
We are going to write a program to produce a bonus report.
a. The payroll records have been sorted into ascending sequence by office number within territory number. There are an unknown number of territories, but every territory will have exactly two offices, and every office will have exactly 10 employees. Thus all employees within office 01 within territory 01 will appear before employee records for office 02 within territory 01, and so on.
b. Only employees who were hired before 1994 are entitled to a 10% bonus.
c. Print the names of all the employees and their bonuses. Print a separate page for each office within each territory. Use a nested PERFORM to achieve the page breaks for each office within each territory. (The WRITE...AFTER ADVANCING PAGE will issue a page break)
Record layout for the input file is as follows:
Field Name Size Type
Employee No. 5 Alphanumeric
Employee Name 20 Alphanumeric
Location Code: Group
Territory No. 2 Alphanumeric
Office No. 2 Alphanumeric
Annual Salary 6 Numeric (integer)
unused 29 Alphanumeric
Date Hired 6 Format: MMDDYY
unused 10 Alphanumeric
===========================================
Total Size of Rec 80
The following is the layout for the report. The first 9 lines are the headers. Line 11 describes the detail.
1 2 3 4 5 6
+0+0+0+0+0+0
1
2 BONUS REPORT PAGE 99
3 99/99/9999
4
5 TERRITORY — XX
6
7 OFFICE — XX
8
9 EMPLOYEE NAME BONUS
10
11 XXXXXXXXXXXXXXXXXXXX $ZZ,ZZZ.99
Extra Credit
For up to 10 point of extra credit you can modify the assignment 5 program to assume that the number employees is unknown. Also assume that the number of territories is unknown and the number of offices within each territory is unknown. If you choose to do the extra credit, complete the original assignment 5 as defined above. Then make a copy of the program and modify the copy to get the extra credit. You should then hand in the two programs.
This is what I've produced, however, it's not working, any insight on what I'm doing wrong would be helpful?
IDENTIFICATION DIVISION.
PROGRAM-ID. BNSRPT.
AUTHOR. AR.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-FILE ASSIGN TO "C:\EMPPAYRL.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO "C:\BONUS.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-FILE
RECORD CONTAINS 80 CHARACTERS.
01 EMPLOYEE-INPUT-REC PIC X(80).
FD PRINT-FILE
RECORD CONTAINS 100 CHARACTERS.
01 PRINT-LINE PIC X(100).
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD-IN.
05 EMPLOYEE-NO PIC X(5).
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-LOCATION-CODE.
10 EMPLOYEE-TERRITORY-NO PIC X(2).
10 EMPLOYEE-OFFICE-NO PIC X(2).
05 EMPLOYEE-ANNUAL-SALARY PIC 9(6).
05 EMPLOYEE-HIRE-DATE.
10 EMP-HIRE-DATE-MM PIC X(2).
10 EMP-HIRE-DATE-DD PIC X(2).
10 EMP-HIRE-DATE-YY PIC X(2).
05 BONUS PIC X(6).
01 IND-BONUS-INFORMATION.
05 IND-BONUS PIC 9(2)V99 VALUE .10.
01 PROGRAM-SWITCHES.
05 WS-EMPLOYEE-EOF PIC X(1) VALUE 'N'.
05 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
01 PAGE-AND-LINE-COUNTERS.
05 LINE-COUNT PIC 9(2) VALUE 6.
05 PAGE-COUNT PIC 9(2) VALUE ZEROES.
05 LINES-PER-PAGE PIC 9(2) VALUE 10.
01 TODAYS-DATE-AREA.
05 TODAYS-MONTH PIC 99.
05 TODAYS-DAY PIC 99.
05 TODAYS-YEAR PIC 99.
01 HEADING-LINE-ONE.
05 FILLER PIC X(26) VALUE SPACES.
05 FILLER PIC X(12) VALUE 'BONUS REPORT'.
05 FILLER PIC X(22) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'PAGE'.
05 HDG-PAGE-NUMBER PIC Z9.
05 FILLER PIC X(3) VALUE SPACES.
01 HEADING-LINE-TWO.
05 FILLER PIC X(55) VALUE SPACES.
05 HDG-DATE PIC X(8).
05 FILLER PIC X(3) VALUE SPACES.
01 HEADING-LINE-THREE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(16) VALUE ' TERRITORY - '.
01 HEADING-LINE-FOUR.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(11) VALUE ' OFFICE - '.
01 HEADING-LINE-FIVE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(15) VALUE 'EMPLOYEE NAME -'.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'BONUS'.
05 FILLER PIC X(2) VALUE SPACES.
01 DETAIL-LINE.
05 DET-EMPLOYEE-TERRITORY-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-OFFICE-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-NAME PIC X(20).
05 FILLER PIC X(10) VALUE SPACES.
05 DET-BONUS-AMOUNT PIC $ZZ,ZZZZ.99.
PROCEDURE DIVISION.
PREPARE-EMPLOYEE-INPUT-REC.
OPEN INPUT EMPLOYEE-FILE
OUTPUT PRINT-FILE.
PERFORM GET-TODAYS-DATE.
PERFORM UNTIL DATA-REMAINS-SWITCH = 'N'
READ EMPLOYEE-FILE INTO EMPLOYEE-RECORD-IN
AT END
MOVE 'N' TO DATA-REMAINS-SWITCH
NOT AT END
PERFORM PROCESS-EMPLOYEE-RECORD
END-READ
END-PERFORM.
CLOSE EMPLOYEE-FILE
PRINT-FILE.
STOP RUN.
GET-TODAYS-DATE.
ACCEPT TODAYS-DATE-AREA FROM DATE.
STRING TODAYS-MONTH '/' TODAYS-DAY '/' TODAYS-YEAR
DELIMITED BY SIZE INTO HDG-DATE
END-STRING.
PROCESS-EMPLOYEE-RECORD.
IF EMP-HIRE-DATE-YY <= 1994
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME
WRITE PRINT-LINE.
COMPUTE IND-BONUS = EMPLOYEE-ANNUAL-SALARY * IND-BONUS
MOVE BONUS TO DET-BONUS-AMOUNT
PERFORM WRITE-DETAIL-LINE.
PROCESS-OFFICE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.
WRITE-HEADING-LINE.
MOVE 1 TO LINE-COUNT.
ADD 1 TO PAGE-COUNT.
MOVE PAGE-COUNT TO HDG-PAGE-NUMBER.
WRITE PRINT-LINE FROM HEADING-LINE-ONE
AFTER ADVANCING PAGE.
WRITE PRINT-LINE FROM HEADING-LINE-TWO
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-THREE
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FOUR
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FIVE
AFTER ADVANCING 2 LINES.
WRITE-DETAIL-LINE.
MOVE TODAYS-DAY TO HDG-DATE.
MOVE TODAYS-MONTH TO HDG-DATE.
MOVE TODAYS-YEAR TO HDG-DATE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME.
MOVE BONUS TO DET-BONUS-AMOUNT.
WRITE PRINT-LINE FROM DETAIL-LINE
AFTER ADVANCING 2 LINES.
ADD 1 TO LINE-COUNT.
We are going to write a program to produce a bonus report.
a. The payroll records have been sorted into ascending sequence by office number within territory number. There are an unknown number of territories, but every territory will have exactly two offices, and every office will have exactly 10 employees. Thus all employees within office 01 within territory 01 will appear before employee records for office 02 within territory 01, and so on.
b. Only employees who were hired before 1994 are entitled to a 10% bonus.
c. Print the names of all the employees and their bonuses. Print a separate page for each office within each territory. Use a nested PERFORM to achieve the page breaks for each office within each territory. (The WRITE...AFTER ADVANCING PAGE will issue a page break)
Record layout for the input file is as follows:
Field Name Size Type
Employee No. 5 Alphanumeric
Employee Name 20 Alphanumeric
Location Code: Group
Territory No. 2 Alphanumeric
Office No. 2 Alphanumeric
Annual Salary 6 Numeric (integer)
unused 29 Alphanumeric
Date Hired 6 Format: MMDDYY
unused 10 Alphanumeric
===========================================
Total Size of Rec 80
The following is the layout for the report. The first 9 lines are the headers. Line 11 describes the detail.
1 2 3 4 5 6
+0+0+0+0+0+0
1
2 BONUS REPORT PAGE 99
3 99/99/9999
4
5 TERRITORY — XX
6
7 OFFICE — XX
8
9 EMPLOYEE NAME BONUS
10
11 XXXXXXXXXXXXXXXXXXXX $ZZ,ZZZ.99
Extra Credit
For up to 10 point of extra credit you can modify the assignment 5 program to assume that the number employees is unknown. Also assume that the number of territories is unknown and the number of offices within each territory is unknown. If you choose to do the extra credit, complete the original assignment 5 as defined above. Then make a copy of the program and modify the copy to get the extra credit. You should then hand in the two programs.
This is what I've produced, however, it's not working, any insight on what I'm doing wrong would be helpful?
IDENTIFICATION DIVISION.
PROGRAM-ID. BNSRPT.
AUTHOR. AR.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-FILE ASSIGN TO "C:\EMPPAYRL.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO "C:\BONUS.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-FILE
RECORD CONTAINS 80 CHARACTERS.
01 EMPLOYEE-INPUT-REC PIC X(80).
FD PRINT-FILE
RECORD CONTAINS 100 CHARACTERS.
01 PRINT-LINE PIC X(100).
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD-IN.
05 EMPLOYEE-NO PIC X(5).
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-LOCATION-CODE.
10 EMPLOYEE-TERRITORY-NO PIC X(2).
10 EMPLOYEE-OFFICE-NO PIC X(2).
05 EMPLOYEE-ANNUAL-SALARY PIC 9(6).
05 EMPLOYEE-HIRE-DATE.
10 EMP-HIRE-DATE-MM PIC X(2).
10 EMP-HIRE-DATE-DD PIC X(2).
10 EMP-HIRE-DATE-YY PIC X(2).
05 BONUS PIC X(6).
01 IND-BONUS-INFORMATION.
05 IND-BONUS PIC 9(2)V99 VALUE .10.
01 PROGRAM-SWITCHES.
05 WS-EMPLOYEE-EOF PIC X(1) VALUE 'N'.
05 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
01 PAGE-AND-LINE-COUNTERS.
05 LINE-COUNT PIC 9(2) VALUE 6.
05 PAGE-COUNT PIC 9(2) VALUE ZEROES.
05 LINES-PER-PAGE PIC 9(2) VALUE 10.
01 TODAYS-DATE-AREA.
05 TODAYS-MONTH PIC 99.
05 TODAYS-DAY PIC 99.
05 TODAYS-YEAR PIC 99.
01 HEADING-LINE-ONE.
05 FILLER PIC X(26) VALUE SPACES.
05 FILLER PIC X(12) VALUE 'BONUS REPORT'.
05 FILLER PIC X(22) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'PAGE'.
05 HDG-PAGE-NUMBER PIC Z9.
05 FILLER PIC X(3) VALUE SPACES.
01 HEADING-LINE-TWO.
05 FILLER PIC X(55) VALUE SPACES.
05 HDG-DATE PIC X(8).
05 FILLER PIC X(3) VALUE SPACES.
01 HEADING-LINE-THREE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(16) VALUE ' TERRITORY - '.
01 HEADING-LINE-FOUR.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(11) VALUE ' OFFICE - '.
01 HEADING-LINE-FIVE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(15) VALUE 'EMPLOYEE NAME -'.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'BONUS'.
05 FILLER PIC X(2) VALUE SPACES.
01 DETAIL-LINE.
05 DET-EMPLOYEE-TERRITORY-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-OFFICE-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-NAME PIC X(20).
05 FILLER PIC X(10) VALUE SPACES.
05 DET-BONUS-AMOUNT PIC $ZZ,ZZZZ.99.
PROCEDURE DIVISION.
PREPARE-EMPLOYEE-INPUT-REC.
OPEN INPUT EMPLOYEE-FILE
OUTPUT PRINT-FILE.
PERFORM GET-TODAYS-DATE.
PERFORM UNTIL DATA-REMAINS-SWITCH = 'N'
READ EMPLOYEE-FILE INTO EMPLOYEE-RECORD-IN
AT END
MOVE 'N' TO DATA-REMAINS-SWITCH
NOT AT END
PERFORM PROCESS-EMPLOYEE-RECORD
END-READ
END-PERFORM.
CLOSE EMPLOYEE-FILE
PRINT-FILE.
STOP RUN.
GET-TODAYS-DATE.
ACCEPT TODAYS-DATE-AREA FROM DATE.
STRING TODAYS-MONTH '/' TODAYS-DAY '/' TODAYS-YEAR
DELIMITED BY SIZE INTO HDG-DATE
END-STRING.
PROCESS-EMPLOYEE-RECORD.
IF EMP-HIRE-DATE-YY <= 1994
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME
WRITE PRINT-LINE.
COMPUTE IND-BONUS = EMPLOYEE-ANNUAL-SALARY * IND-BONUS
MOVE BONUS TO DET-BONUS-AMOUNT
PERFORM WRITE-DETAIL-LINE.
PROCESS-OFFICE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.
WRITE-HEADING-LINE.
MOVE 1 TO LINE-COUNT.
ADD 1 TO PAGE-COUNT.
MOVE PAGE-COUNT TO HDG-PAGE-NUMBER.
WRITE PRINT-LINE FROM HEADING-LINE-ONE
AFTER ADVANCING PAGE.
WRITE PRINT-LINE FROM HEADING-LINE-TWO
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-THREE
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FOUR
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FIVE
AFTER ADVANCING 2 LINES.
WRITE-DETAIL-LINE.
MOVE TODAYS-DAY TO HDG-DATE.
MOVE TODAYS-MONTH TO HDG-DATE.
MOVE TODAYS-YEAR TO HDG-DATE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME.
MOVE BONUS TO DET-BONUS-AMOUNT.
WRITE PRINT-LINE FROM DETAIL-LINE
AFTER ADVANCING 2 LINES.
ADD 1 TO LINE-COUNT.