PT-ENTRIES.">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Program 30 -- COBOL-2. *TABLE DATA EMBEDDED FOR REDEFINES OF TABLE BELOW ************************************************* 01 TABLE-WORK-AREA. 05 PT-SUB.

Similar presentations


Presentation on theme: "Program 30 -- COBOL-2. *TABLE DATA EMBEDDED FOR REDEFINES OF TABLE BELOW ************************************************* 01 TABLE-WORK-AREA. 05 PT-SUB."— Presentation transcript:

1 Program COBOL-2

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.

3 *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.

4 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

5 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 ……...

6 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.

7 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

8 **************************************************** * 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 * **********************************************************

9 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).

10 INPUT-OUTPUT SECTION. ********************** FILE-CONTROL. 2 - SELECT (statements) ASSIGN TO SYS007-UR-2540R-S. ASSIGN TO SYS006-UR-1403-S. DATA DIVISION. Program - 30

11 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

12 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".

13 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.

14 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).

15 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.

16 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.

17 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

18 * * * 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.

19 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

20 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.

21 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

22 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!


Download ppt "Program 30 -- COBOL-2. *TABLE DATA EMBEDDED FOR REDEFINES OF TABLE BELOW ************************************************* 01 TABLE-WORK-AREA. 05 PT-SUB."

Similar presentations


Ads by Google