Program COBOL-2
*TABLE DATA EMBEDDED FOR REDEFINES OF TABLE BELOW ************************************************* 01 TABLE-WORK-AREA. 05 PT-SUB PIC PT-ENTRIES PIC 99 VALUE PT-PET-PROGRAM-DATA. 05 PIC X(24) VALUE "DOG 11". 05 PIC X(24) VALUE "CAT 18". ETC PT-TABLE REDEFINES PT-PET-PROGRAM-DATA. 05 PT-TABLE-DEFINE OCCURS 6 TIMES. 10 PT-DESCRIPTION PIC X(20). 10 PT-NUMBER-PETS PIC 9999.
*TABLE DATA EMBEDDED FOR REDEFINES OF TABLE BELOW ************************************************* 01 TABLE-WORK-AREA. 05 PT-SUB PIC PT-ENTRIES PIC 99 VALUE PT-PET-PROGRAM-DATA. 05 PIC X(24) VALUE "DOG 11". 05 PIC X(24) VALUE "CAT 18". ETC PT-TABLE REDEFINES PT-PET-PROGRAM-DATA. 05 PT-TABLE-DEFINE OCCURS 6 TIMES. 10 PT-DESCRIPTION PIC X(20). 10 PT-NUMBER-PETS PIC PROCEDURE DIVISION PERFORM B-200-PRINT-EMBEDDED-TABLE VARYING PT-SUB FROM 1 BY 1 UNTIL PT-SUB > PT-ENTRIES.
01 TABLE-WORK-AREA. 05 PT-SUB PIC PT-ENTRIES PIC 99 VALUE PT-PET-PROGRAM-DATA. 05 PIC X(27) VALUE ”100DOG 11". 05 PIC X(27) VALUE ”110CAT 18". ETC PT-TABLE REDEFINES PT-PET-PROGRAM-DATA. 05 PT-TABLE-DEFINE OCCURS 6 TIMES. 10 PT-CODE PIC XXX. 10 PT-DESCRIPTION PIC X(20). 10 PT-NUMBER-PETS PIC PROCEDURE DIVISION PERFORM B-200-PRINT-EMBEDDED-TABLE VARYING PT-SUB FROM 1 BY 1 UNTIL PT-SUB > PT-ENTRIES. READ Added Code Need for PIC & Code
01 DT-DEGREE-PROGRAM-DATA. 05 FILLER PIC X(32) VALUE "100ACCOUNTING B.S.". 05 FILLER PIC X(32) VALUE "110ADMINISTRATIVE MANAGEMENTB.S.". 05 FILLER PIC X(32) VALUE "120BUSINESS & HUMANITIES B.A.". 05 FILLER PIC X(32) VALUE "130BUSINESS ECONOMICS B.A.". 05 FILLER PIC X(32) VALUE "140FINANCE B.S.". 05 FILLER PIC X(32) VALUE "150HUMAN RELATIONS B.A.". 05 FILLER PIC X(32) VALUE "160INTERNATIONAL MANAGEMENT B.S.". 05 FILLER PIC X(32) VALUE "170INDUSTRIAL MANAGEMENT B.S.". ETC ……...
1100AccountingB.S. 2110Administrative Management B.S. 3120Business & HumanitiesB.A. 4130Business EconomicesB.A. 5140FinanceB.A. 6150Human RelationsB.S. 7160International ManagementB.S. 8170Industrial ManagementB.S. 9180MarketingB.S TransportationB.S Prelegal StudiesB.A Administration of JusticeB.A Health Services MgmtB.S Hotel & Rest. MgmtB.S Information SystemsB.S Telecommunication MgmtB.S Medical Record MgmtB.S Political ScienceB.A Public AdministrationB.A Security ManagementB.S.
Program - 30 Input file Output (report) Table Data Insert where? DATA DIVISION b/4 PROCEDURE DIVISION Value of table has PIC clause defining entire field how do we break the table entries down? -- Student File -- Program-Degree-Listing
**************************************************** * PROGRAM NARRATIVE * * * Mod Date Initials Description * * **************************************************** * THIS PROGRAM HAS A DEGREE LOOKUP USING TABLES.* * A DEGREE-PROGRAM LOOKUP IS REQUIRED SO THAT * * THE PROGRAM-NAME AND DEGREE FOR EACH * * STUDENT CAN BE PRINTED ON THE STUDENT * * DEGREE-PROGRAM LIST. * * INPUT: STUDENT-FILE - STUDENT MASTER FILE * * * OUTPUT: DEGREE-LISTING - DEGREE LIST REPORT * **********************************************************
Program DT-Degree-Data. 05 PIC X(32) Value “100ACCOUNTING B.S.”. 05 PIC X(32) Value “110ADMINISTRATIVE MANAGEMENTB.S.” 05 etc…… 01 DT-Degree-Table REDEFINES DT-Degree-Data. 05 DT-Degree-EntryOCCURS 20 TIMES Indexed BY DT-Index. 10 DT-Major-CodePIC XXX. 10 DT-Program-NamePIC X(25). 10 DT-DegreePIC X(4).
INPUT-OUTPUT SECTION. ********************** FILE-CONTROL. 2 - SELECT (statements) ASSIGN TO SYS007-UR-2540R-S. ASSIGN TO SYS006-UR-1403-S. DATA DIVISION. Program - 30
FILE SECTION. ************** * Comments * ******************************************* FD (key name of file from SELECT statement) RECORD CONTAINS 80 CHARACTERS LABEL RECORDS ARE OMITTED. 01 (key in RECORD name of file). 05 PIC X(80). Program - 30
FD DEGREE-PROGRAM-LIST RECORD CONTAINS 132 CHARACTERS LABEL RECORDS ARE OMITTED. 01 REPORT-LINE. 05 PIC X(132). * WORKING-STORAGE SECTION. Program - 30 * SWITCHES * 01 WS-SWITCHES. 05 WS-END-OF-FILE-SWITCH PIC X(3). 88 END-OF-FILE VALUE "YES".
Program WS-REPORT-CONTROLS. 05 WS-PAGE-COUNT PIC S9(3). 05 WS-LINES-PER-PAGEPIC S9(2) VALUE WS-LINES-USED PIC S9(2). 05 WS-LINE-SPACING PIC S9(2). * REPORT HEADINGS FOR ??? REPORT * 01 DT-TABLE-CONTROLS. 05 DT-ENTRY-FOUND-SWITCH PIC X(3). 88 DT-ENTRY-FOUND VALUE "YES". 88 DT-END-OF-TABLE VALUE "END". 05 DT-SUB PIC 99 VALUE 1.
Program - 30 Value of table has PIC clause defining entire field how do we break the table entries down? 01 DT-DEGREE-PROGRAM-TABLE REDEFINES DT-DEGREE-PROGRAM-DATA. 05 DT-DEGREE-PROGRAM-ENTRY OCCURS 20 TIMES. 10 DT-MAJOR-CODE PIC X(3). 10 DT-PROGRAM-NAME PIC X(25). 10 DT-DEGREE PIC X(4).
Program - 30 PROCEDURE DIVISION. 100-Main-MOD. Open Input Output Perform 100-Initialize-Variable-fields. Perform 800-Read-Student-Record. Perform 200-Process-Student-Record until E-O-F. Perform 900-Wrap-up.
Program - 30 PROCEDURE DIVISION. 100-Main-MOD. Open Input Output Perform 100-Initialize-Variable-fields. Perform 800-Read-Student-Record. Perform 200-Process-Student-Record until E-O-F. Perform 900-Wrap-up. 800-Read-Student-Record. Read Student-File -- on SELECT statement FD entry READ STUDENT-FILE INTO SR-STUDENT-RECORD AT END MOVE "YES" TO WS-END-OF-FILE-SWITCH.
PROCEDURE DIVISION. 100-Main-MOD. Open Input & Output Perform Until ARE-THERE-MORE-RECORDS = “NO “ Read ….. AT END Move “NO “ To ARE-THERE-MORE-RECORDS NOT AT END Perform 200-Process-Student-Record End-Read End-Perform. Perform 900-Wrap-up. Program - 30 In-line PERFORM COBOL-85
* * * DATE, TIME AND PRINT CONTROL FIELDS * * * 01 PRINT-CONTROL-FIELDS. 05 LINE-COUNT PIC S99 VALUE LINES-ON-PAGE PIC S99 VALUE SPACE-CONTROL PIC S9 VALUE +1. Program PROCESS-STUDENT-RECORD. IF LINE-COUNT > LINES-ON-PAGE PERFORM 300-PRINT-HEADINGS.
MOVE " " TO DT-ENTRY-FOUND-SWITCH. PERFORM 210-LOOKUP-DEGREE-PROGRAM VARYING DT-SUB FROM 1 BY 1 UNTIL DT-ENTRY-FOUND OR DT-END-OF-TABLE. 210-LOOKUP-DEGREE-PROGRAM. IF SR-MAJOR-CODE = DT-MAJOR-CODE (DT-SUB) MOVE "YES" TO DT-ENTRY-FOUND-SWITCH ELSE IF DT-SUB > 20 MOVE "END" TO DT-ENTRY-FOUND-SWITCH. OR DT-MAJOR-CODE(DT-Sub) > SR-MAJOR-CODE
IF DT-ENTRY-FOUND MOVE DT-PROGRAM-NAME (DT-SUB) TO DL-PROGRAM-NAME MOVE DT-DEGREE (DT-SUB) TO DL-DEGREE ELSE MOVE "MAJOR CODE NOT IN TABLE" TO DL-PROGRAM-NAME MOVE "****" TO DL-DEGREE.
300-PRINT-HEADINGS. ADD 1 TO AC-PAGE-COUNT. MOVE AC-PAGE-COUNT TO RH-PAGE. MOVE RH-LINE-1 TO PRINT-LINE. PERFORM 870-WRITE-TOP. MOVE RH-LINE-2 TO PRINT-LINE. MOVE 1 TO SPACE-CONTROL. PERFORM 850-WRITE-REPORT-LINE MOVE RH-LINE-3 TO PRINT-LINE. Program - 30
850-WRITE-REPORT-LINE. WRITE PRINT-LINE AFTER ADVANCING SPACE-CONTROL. ADD SPACE-CONTROL TO LINE-COUNT. 870-WRITE-TOP. WRITE PRINT-LINE AFTER ADVANCING PAGE. MOVE 1 TO LINE-COUNT. Program Wrap-Up. Close File1 File2 Stop Run.-- COBOL 85 Close statement unnecessary!