shellshell
Technical User
I am stuck on instructions for a program I was given minimal specs for. Here is the info I was give:
"Write the COBOL instructions to update the employee hours and earnings table. The hours and earnings have been calculated and are contained in the fields cal-hours and cal-erngs.
This table will contain information for 100 employees. Each employee will have been able to work in up to 25 departments.
Each department will allow for 5 jobs.
All fields in the table have been initialized to spaces and zeros.
01 HRSERN-TBL.
05 HRSERN-IT1 OCCURS 100 TIMES.
10 HRSERN-EMP PICTURE X(4).
10 HRSERN-IT2 OCCURS 25 TIMES.
15 HRSERN-DEP PICTURE XX.
15 HRSERN-IT3 OCCURS 5 TIMES.
20 HRSERN-JOB PICTURE XX.
20 HRSERN-HRS PICTURE 9(4)V99.
20 HRSERN-ERN PICTURE 9(6)V99.
Listed below are some additional fields that may be used in your instructions. some of these you may not use and feel free to add any of your own.
01 HRSERN-SB1 PICTURE 9(4).
01 HRSERN-SB2 PICTURE 9(4).
01 HRSERN-SB3 PICTURE 9(4).
01 HRSERN-SB4 PICTURE 9(4).
01 CAL-HOURS PICTURE 9(4)V99.
01 CAL-ERNGS PICTURE 9(6)V99.
01 INP-EMP-ID PICTURE X(4).
01 INP-DEP-ID PICTURE XX.
01 INP-JOB-ID PICTURE XX.
01 PERFORM-DN1 PICTURE X.
01 PERF0RM-DN2 PICTURE X.
01 PERFORM-DN3 PICTURE X.
01 PERFORM-DN4 PICTURE X. "
I am concerned with the read I have started, not sure if I should have the priming read, and then a Read routine or not. Then I am also confused with the three-level table with the Perform Varying statements. I am not quite sure I am thinking this through correctly. Here is what I have so far.
FD EMPLOYEE-ERNGS-FILE
RECORD CONTAINS 18 CHARACTERS
DATA RECORD IS EMPLOYEE-ERNGS-RECORD.
01 EMPLOYEE-ERNGS-RECORD.
05 INP-EMP-ID PICTURE X(4).
05 INP-DEP-ID PICTURE XX.
05 INP-JOB-ID PICTURE XX.
05 CAL-HOURS PICTURE 9(4)V99.
05 CAL-ERNGS PICTURE 9(6)V99.
01 SWITCHES-AND-COUNTERS.
05 EOF-SWITCH PICTURE X VALUE 'N'
05 EMP-COUNT PICTURE 9(3).
05 DEPT-COUNT PICTURE 9(3).
05 JOB-COUNT PICTURE 9(3).
(Just wanted to give you the file coming in. I'm not really running a report, yet, so I haven't set up the detail fields or anything yet.)
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT EMPLOYEE-ERNGS-FILE
OUTPUT (????NOT SURE ABOUT THIS YET)
PERFORM UNTIL EOF-SWITCH = 'Y'
READ EMPLOYEE-ERNGS-FILE
AT END
MOVE 'Y' TO EOF-SWITCH
NOT AT END
PERFORM 200-PROCESS-HOURS-AND-EARNINGS
END PERFORM.
PERFORM 220-UPDATE-CURRENT-TABLE.
CLOSE EMPLOYEE-ERNGS-FILE
(??? --- ???).
STOP RUN.
200-PROCESS-HOURS-AND-EARNINGS.
PERFORM 300-EMP-ID-RTN
VARYING HRSERN-SB1 FROM 1 BY 1
UNTIL HRSERN-SB1 > 100
END PERFORM.
IF HRSERN-SB1 > 100
MOVE 'Y' TO EOF-SWITCH
END-IF.
300-EMP-ID-RTN.
IF INP-EMP-ID NOT = WS-EMP-ID
INITIALIZE WS-EMP-ID
MOVE INP-EMP-ID TO WS-EMP-ID
ADD 1 TO EMP-COUNT
PERFORM 400-DEPT-RTN
VARYING HRSERN-SB2 FROM 1 BY 1
UNTIL HRSERN-SB2 > 25
IF HRSERN-SB2 > 25
MOVE 'Y' TO PERFORM-DN1
END-IF
END PERFORM
END-IF.
400-DEPT-RTN.
IF INP-DEPT-ID NOT = WS-DEPT-ID
INITIALIZE WS-DEPT-ID
MOVE INP-DEPT-ID TO WS-DEPT-ID
ADD 1 TO WS-DEPT-ID
PERFORM 500-JOB-RTN
VARYING HRSERN-SB3 FROM 1 BY 1
UNTIL HRSERN-SB3 > 5
IF HRSERN-SB3 > 5
MOVE 'Y' TO PERFORM-DN2
END-IF
END PERFORM
END-IF.
500-JOB-RTN.
IF INP-JOB-ID NOT = WS-JOB-ID
INITIALIZE WS-JOB-ID
MOVE INP-JOB-ID TO WS-JOB-ID
ADD 1 TO JOB-COUNT
PERFORM 600-CALCULATE-NEW-ERNGS
Ok this is where I am stuck. First of all if I have one employee working in more than one dept. or more than one job I need to make sure that the earnings are getting to the correct dept. and job. I don't know how I am going to keep that tracked to hold the dept. id and the job id to calculate the earnings. Does it sound like I need to be calculating the earnings per employee, department, and job? This is why I haven't designed any report fields yet.
Also, am I even doing the Perform Varying correct? Do I want to check for > 25 for HRSERN-SB2 and > 5 for HRSERN-SB3, or should I be setting a different flag? I set the PERFORM-DN#, but I don't know where to take it after that. Do I need a priming READ, and then a READ-EMPLOYEE-ERNGS-RECORD routine as well? Please, if anyone can offer any help and/or suggestions it would greatly appreciated. I don't have much time left on this and have struggled for awhile with it.
Thank you in advance,
shellshell
"Write the COBOL instructions to update the employee hours and earnings table. The hours and earnings have been calculated and are contained in the fields cal-hours and cal-erngs.
This table will contain information for 100 employees. Each employee will have been able to work in up to 25 departments.
Each department will allow for 5 jobs.
All fields in the table have been initialized to spaces and zeros.
01 HRSERN-TBL.
05 HRSERN-IT1 OCCURS 100 TIMES.
10 HRSERN-EMP PICTURE X(4).
10 HRSERN-IT2 OCCURS 25 TIMES.
15 HRSERN-DEP PICTURE XX.
15 HRSERN-IT3 OCCURS 5 TIMES.
20 HRSERN-JOB PICTURE XX.
20 HRSERN-HRS PICTURE 9(4)V99.
20 HRSERN-ERN PICTURE 9(6)V99.
Listed below are some additional fields that may be used in your instructions. some of these you may not use and feel free to add any of your own.
01 HRSERN-SB1 PICTURE 9(4).
01 HRSERN-SB2 PICTURE 9(4).
01 HRSERN-SB3 PICTURE 9(4).
01 HRSERN-SB4 PICTURE 9(4).
01 CAL-HOURS PICTURE 9(4)V99.
01 CAL-ERNGS PICTURE 9(6)V99.
01 INP-EMP-ID PICTURE X(4).
01 INP-DEP-ID PICTURE XX.
01 INP-JOB-ID PICTURE XX.
01 PERFORM-DN1 PICTURE X.
01 PERF0RM-DN2 PICTURE X.
01 PERFORM-DN3 PICTURE X.
01 PERFORM-DN4 PICTURE X. "
I am concerned with the read I have started, not sure if I should have the priming read, and then a Read routine or not. Then I am also confused with the three-level table with the Perform Varying statements. I am not quite sure I am thinking this through correctly. Here is what I have so far.
FD EMPLOYEE-ERNGS-FILE
RECORD CONTAINS 18 CHARACTERS
DATA RECORD IS EMPLOYEE-ERNGS-RECORD.
01 EMPLOYEE-ERNGS-RECORD.
05 INP-EMP-ID PICTURE X(4).
05 INP-DEP-ID PICTURE XX.
05 INP-JOB-ID PICTURE XX.
05 CAL-HOURS PICTURE 9(4)V99.
05 CAL-ERNGS PICTURE 9(6)V99.
01 SWITCHES-AND-COUNTERS.
05 EOF-SWITCH PICTURE X VALUE 'N'
05 EMP-COUNT PICTURE 9(3).
05 DEPT-COUNT PICTURE 9(3).
05 JOB-COUNT PICTURE 9(3).
(Just wanted to give you the file coming in. I'm not really running a report, yet, so I haven't set up the detail fields or anything yet.)
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT EMPLOYEE-ERNGS-FILE
OUTPUT (????NOT SURE ABOUT THIS YET)
PERFORM UNTIL EOF-SWITCH = 'Y'
READ EMPLOYEE-ERNGS-FILE
AT END
MOVE 'Y' TO EOF-SWITCH
NOT AT END
PERFORM 200-PROCESS-HOURS-AND-EARNINGS
END PERFORM.
PERFORM 220-UPDATE-CURRENT-TABLE.
CLOSE EMPLOYEE-ERNGS-FILE
(??? --- ???).
STOP RUN.
200-PROCESS-HOURS-AND-EARNINGS.
PERFORM 300-EMP-ID-RTN
VARYING HRSERN-SB1 FROM 1 BY 1
UNTIL HRSERN-SB1 > 100
END PERFORM.
IF HRSERN-SB1 > 100
MOVE 'Y' TO EOF-SWITCH
END-IF.
300-EMP-ID-RTN.
IF INP-EMP-ID NOT = WS-EMP-ID
INITIALIZE WS-EMP-ID
MOVE INP-EMP-ID TO WS-EMP-ID
ADD 1 TO EMP-COUNT
PERFORM 400-DEPT-RTN
VARYING HRSERN-SB2 FROM 1 BY 1
UNTIL HRSERN-SB2 > 25
IF HRSERN-SB2 > 25
MOVE 'Y' TO PERFORM-DN1
END-IF
END PERFORM
END-IF.
400-DEPT-RTN.
IF INP-DEPT-ID NOT = WS-DEPT-ID
INITIALIZE WS-DEPT-ID
MOVE INP-DEPT-ID TO WS-DEPT-ID
ADD 1 TO WS-DEPT-ID
PERFORM 500-JOB-RTN
VARYING HRSERN-SB3 FROM 1 BY 1
UNTIL HRSERN-SB3 > 5
IF HRSERN-SB3 > 5
MOVE 'Y' TO PERFORM-DN2
END-IF
END PERFORM
END-IF.
500-JOB-RTN.
IF INP-JOB-ID NOT = WS-JOB-ID
INITIALIZE WS-JOB-ID
MOVE INP-JOB-ID TO WS-JOB-ID
ADD 1 TO JOB-COUNT
PERFORM 600-CALCULATE-NEW-ERNGS
Ok this is where I am stuck. First of all if I have one employee working in more than one dept. or more than one job I need to make sure that the earnings are getting to the correct dept. and job. I don't know how I am going to keep that tracked to hold the dept. id and the job id to calculate the earnings. Does it sound like I need to be calculating the earnings per employee, department, and job? This is why I haven't designed any report fields yet.
Also, am I even doing the Perform Varying correct? Do I want to check for > 25 for HRSERN-SB2 and > 5 for HRSERN-SB3, or should I be setting a different flag? I set the PERFORM-DN#, but I don't know where to take it after that. Do I need a priming READ, and then a READ-EMPLOYEE-ERNGS-RECORD routine as well? Please, if anyone can offer any help and/or suggestions it would greatly appreciated. I don't have much time left on this and have struggled for awhile with it.
Thank you in advance,
shellshell