Created
September 28, 2020 11:21
-
-
Save sandeep-sparrow/595a857ff07892df1cd99ef7c10c3cad to your computer and use it in GitHub Desktop.
Using One-Dimensional Table to load records from external file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A111BILLY BIGGS NCPROGRAMMER/ANALYST 0320000505007500COBOL Y | |
B222FRED TANAKA ALGRAPHIC DESIGNER 0071110506005000JAVASCRIPT Y | |
C333SALLY FIDDLER NCDATABASE ADMIN 1110220515017500CDB2 N | |
A111LEONARD STEIN NYJES/JCL SPECIALIST 0220330510027500COBOL Y | |
A111AL YANKOV NCPROGRAMMER/ANALYST 0110000504017500JCL L Y | |
B222KYUHEE PARK NYSYSTESM PROGRAMMER 0410300504027500ASSEMBLER Y | |
D444MEL HUDAK NCMANAGER 0640900506537500VISIO N | |
B333CARLOS RAMOS NYPROGRAMMER/ANALYST 0410100511011100COBOL Y | |
B222ELIZABETH W ALSYSTEMS ARCHITECT 0190200545433300ECLIPSE N | |
B222MILLARD FILL CAPROGRAMMER/ANALYST 0980030521044500COBOL N | |
D444SAMUEL ADAMS NCGRAPHIC DESIGNER 1040040205007500JAVA SERVER PAGES Y | |
A333KANDACE SPRINGSCAPROGRAMMER/ANALYST 2000000205017500COBOL Y | |
B222DAVID SANBORN ALDATABASE ADMNIN 06330003050275SQL L N | |
A111SUE FERRELL NCGRAPHIC DESIGNER 0050870405037500MFS AND BMS Y | |
C333ARUN GUPTA NYPROGRAMMER/ANALYST 0755130505047500COBOL Y | |
B222RVENKAT B NCENTRY-LEVERL PROG 0184020205011100COBOL Y | |
B222IGOR KRUGS CADATABASE ADMIN 1329000305022200BANDLE Y | |
C333HAL LEONARD CASYSTERMS PROGRAMMER 0690210405033300MVS REXX N | |
D444DEEGEGREEN NYPROGRAMMER/ANALYST 1540310655044400COBOL N | |
A111KATHY TUPPER NCPROGRAMMER/ANALYST 1120000405055500COBOL Y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project A111 employee report | |
EMPLOYEE NAME | PROJECT NAME | |
BILLY BIGGS A111 | |
LEONARD STEIN A111 | |
AL YANKOV A111 | |
SUE FERRELL A111 | |
KATHY TUPPER A111 | |
NC state employee with on call support | |
EMPLOYEE NAME | STATE OFFICE | ON CALL | |
BILLY BIGGS NC Y | |
AL YANKOV NC Y | |
SAMUEL ADAMS NC Y | |
SUE FERRELL NC Y | |
RVENKAT B NC Y | |
KATHY TUPPER NC Y | |
Total project A111 expense report | |
Total expense: 232.90$ | |
Total expense of all projects report | |
Total expenses: 872.79$ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IDENTIFICATION DIVISION. | |
PROGRAM-ID. TABLES01. | |
* | |
ENVIRONMENT DIVISION. | |
INPUT-OUTPUT SECTION. | |
FILE-CONTROL. | |
SELECT INPUT-FILE ASSIGN TO EMPROJ | |
ORGANIZATION IS SEQUENTIAL | |
FILE STATUS IS FILE-STATUS-WS. | |
* | |
DATA DIVISION. | |
FILE SECTION. | |
* | |
FD INPUT-FILE RECORDING MODE F | |
RECORD CONTAINS 80 CHARACTERS. | |
01 EMP-PROJECT-TABLE-I. | |
05 EMP-PROJECT-I PIC X(4). | |
05 EMP-NAME-I PIC X(15). | |
05 EMP-STATE-OFFICE-I PIC X(02). | |
05 EMP-PROJECT-POSITION-I PIC X(20). | |
05 EMP-NBR-DAYS-ON-PROJ-I PIC 9(03). | |
05 EMP-NBR-OT-HOURS-I PIC 9(03). | |
05 EMP-PER-DAY-BILLING-RATE-I PIC 9(03)V99. | |
05 EMP-PER-HOUR-OT-RATE-I PIC 9(03)99. | |
05 EMP-LANGUAGE-CERT-I PIC X(20). | |
05 EMP-ON-CALL-I PIC X(01). | |
05 FILLER PIC X(02). | |
* | |
WORKING-STORAGE SECTION. | |
* | |
01 FILE-STATUS-WS. | |
05 OPEN-WS PIC X(02) VALUE SPACES. | |
* | |
77 TABLE-MAX PIC S9(4) COMP VALUE 20. | |
77 SW-END-OF-FILE PIC X(01) VALUE SPACES. | |
88 END-OF-FILE VALUE 'Y'. | |
* | |
01 EMP-PROJECT-TABLE. | |
05 EMP-PROJECT-ITEM OCCURS 20 TIMES | |
ASCENDING KEY IS EMP-NAME | |
INDEXED BY PROJ-IDX. | |
10 EMP-PROJECT PIC X(4). | |
10 EMP-NAME PIC X(15). | |
10 EMP-STATE-OFFICE PIC X(02). | |
10 EMP-PROJECT-POSITION PIC X(20). | |
10 EMP-NBR-DAYS-ON-PROJ PIC 9(03). | |
10 EMP-NBR-OT-HOURS PIC 9(03). | |
10 EMP-PER-DAY-BILLING-RATE PIC 9(03)V99. | |
10 EMP-PER-HOUR-OT-RATE PIC 9(03)99. | |
10 EMP-LANGUAGE-CERT PIC X(20). | |
10 EMP-ON-CALL PIC X(01). | |
10 FILLER PIC X(02). | |
* | |
77 SUM-1 PIC 9(10)V99 VALUE 0. | |
77 SUM-E PIC Z,ZZZ,ZZZ.99. | |
77 GOTCHA PIC X(20). | |
* | |
PROCEDURE DIVISION. | |
* | |
PERFORM 000-HOUSEKEEPING. | |
PERFORM 100-PROCESS-TABLE-DATA. | |
PERFORM 900-WRAP-UP | |
GOBACK. | |
* | |
000-HOUSEKEEPING. | |
* | |
INITIALIZE EMP-PROJECT-TABLE. | |
OPEN INPUT INPUT-FILE. | |
READ INPUT-FILE | |
AT END MOVE 'Y' TO SW-END-OF-FILE. | |
* | |
PERFORM VARYING proj-idx FROM 1 BY 1 | |
UNTIL proj-idx > TABLE-MAX | |
OR END-OF-FILE | |
MOVE EMP-PROJECT-I TO | |
EMP-PROJECT (proj-idx) | |
MOVE EMP-NAME-I TO | |
EMP-NAME (proj-idx) | |
MOVE EMP-STATE-OFFICE-I TO | |
EMP-STATE-OFFICE (proj-idx) | |
MOVE EMP-PROJECT-POSITION-I TO | |
EMP-PROJECT-POSITION (proj-idx) | |
MOVE EMP-NBR-DAYS-ON-PROJ-I TO | |
EMP-NBR-DAYS-ON-PROJ (proj-idx) | |
MOVE EMP-NBR-OT-HOURS-I TO | |
EMP-NBR-OT-HOURS (proj-idx) | |
MOVE EMP-PER-DAY-BILLING-RATE-I TO | |
EMP-PER-DAY-BILLING-RATE (proj-idx) | |
MOVE EMP-PER-HOUR-OT-RATE-I TO | |
EMP-PER-HOUR-OT-RATE (proj-idx) | |
MOVE EMP-LANGUAGE-CERT-I TO | |
EMP-LANGUAGE-CERT (proj-idx) | |
MOVE EMP-ON-CALL-I TO | |
EMP-ON-CALL (proj-idx) | |
READ INPUT-FILE | |
AT END MOVE 'Y' TO SW-END-OF-FILE | |
END-READ | |
END-PERFORM. | |
* | |
100-PROCESS-TABLE-DATA. | |
* | |
DISPLAY "project A111 employee report " | |
DISPLAY " " | |
DISPLAY "EMPLOYEE NAME | PROJECT NAME " | |
DISPLAY " " | |
PERFORM 200-FIND-PROJECT. | |
DISPLAY " " | |
DISPLAY "NC state employee with on call support " | |
DISPLAY " " | |
DISPLAY "EMPLOYEE NAME | STATE OFFICE | ON CALL " | |
DISPLAY " " | |
PERFORM 300-FIND-NC-OT-SKILL. | |
DISPLAY " " | |
DISPLAY "Total project A111 expense report " | |
DISPLAY " " | |
PERFORM 400-TOTAL-PROJ-EXPENSE. | |
DISPLAY " " | |
INITIALIZE SUM-1 SUM-E. | |
DISPLAY "Total expense of all projects report " | |
DISPLAY " " | |
PERFORM 500-TOTAL-ALL-PROJECTS-EXPENSE. | |
DISPLAY " ". | |
* | |
200-FIND-PROJECT. | |
* | |
*** Display all of the Employee names working on project 'A111' | |
* | |
PERFORM VARYING proj-idx FROM 1 BY 1 | |
UNTIL proj-idx > TABLE-MAX *> NEED > for 20th row | |
IF EMP-PROJECT (proj-idx) = 'A111' | |
MOVE 'A111' TO GOTCHA | |
DISPLAY EMP-NAME (PROJ-IDX) " A111" | |
END-IF | |
END-PERFORM. | |
* | |
300-FIND-NC-OT-SKILL. | |
* | |
*** Display all of the Employee names of Programmers in NC | |
*** who are allowed to bill for On-Call work | |
* | |
PERFORM VARYING proj-idx FROM 1 BY 1 | |
UNTIL proj-idx > TABLE-MAX | |
IF EMP-STATE-OFFICE (proj-idx) = 'NC' | |
AND EMP-ON-CALL (proj-idx) = 'Y' | |
DISPLAY EMP-NAME (proj-idx) " NC Y " | |
END-IF | |
END-PERFORM. | |
* | |
400-TOTAL-PROJ-EXPENSE. | |
*** Calculate the total cost for the 'A111' project | |
PERFORM VARYING proj-idx FROM 1 BY 1 | |
UNTIL proj-idx > TABLE-MAX | |
IF EMP-PROJECT (proj-idx) = 'A111' | |
COMPUTE SUM-1 = | |
SUM-1 + EMP-PER-DAY-BILLING-RATE (proj-idx) | |
END-IF | |
END-PERFORM | |
* | |
MOVE SUM-1 TO SUM-E | |
DISPLAY "Total expense: " SUM-E "$". | |
* | |
500-TOTAL-ALL-PROJECTS-EXPENSE. | |
* | |
*** Calculate the total cost for all of the projects | |
* | |
COMPUTE SUM-1 = | |
FUNCTION SUM(EMP-PER-DAY-BILLING-RATE (ALL)) | |
MOVE SUM-1 TO SUM-E | |
DISPLAY "Total expenses:" SUM-E "$". | |
900-WRAP-UP. | |
CLOSE INPUT-FILE. | |
* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment