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

Slides:



Advertisements
Similar presentations
DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
Advertisements

2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Final Total Lines in COBOL Please be sure you can see the speaker notes - they contain additional information!
Cobol application using ODBC or File processing Vandana Janeja CIS 365 With COBOL OR PowerCobol.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
The IDENTIFICATION and ENVIRONMENT DIVISIONS Chapter 2.
Two and three dimension tables Please use speaker notes for additional information!
Any Questions!. Agenda Fun with Functions –how to get the system date Condition Names INDARA and SI Iteration Logical Files Positioning the file pointer.
VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services.
Advanced Sequential Files 1.. Single Record Type Files  In a file which contains only one record type (the kind we have examined so far) the record structure.
Chapter 15 Relative Files.  File organization that converts key field to actual disk address to find location of record No need to look up disk address.
Relative Files.. Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file.
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
1 Chapter 4. To familiarize you with methods used to 1. Access input and output files 2. Read data from an input file 3. Perform simple move operations.
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
Introduction to COBOL. COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
3-1 The DATA DIVISION Chapter Chapter Objectives To familiarize you with Systems design considerations Ways in which data is organized Rules for.
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
Array - adding to array at run time Please see speaker notes for additional information!
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Indexed and Relative File Processing
1 Chapter – 12 Table Lookups Table Codes –Expanded Values –Types of Codes Numeric Alphabetic Alphanumeric.
Edit Programs Please use speaker notes for additional information. Example: payedit.cbl payedit.cbl.
1 The Procedure Division Chapter 4. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage.
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Explanation of SAMPLEIF (if88in1.cbl or if88in1.html) Please use speaker notes for additional information!
1 The Data Division. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage Section –All.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
COBOL Screens Please use speaker notes for additional information!
Structured COBOL Programming, Stern & Stern, 9th Edition CHAPTER 2 Cobol Language Fundamentals.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
1 Review for test 2 Chapters 7, 8, 9, 11, What is wrong with the following paragraphs? PARA-A. PARA-B. ADD A TO B MOVE 0 TO X PERFROM PARA-A PERFORM.
One & Two dimensional Tables Cont.. Table of Major Codes 02ART HISTORY 04BIOLOGY 19CHEMESTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
2-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Lecture 21 ENVIRONMENT DIVISION  defines files external to the program and devices.  contains two sections: 1.CONFIGURATION SECTION.  identifies computers.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
Indexed Files.. Creating an Indexed File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateIndexedFromSeq. * Creates an indexed file.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Any Questions!. Agenda Fun with Functions Externally Described Files Condition Names Iteration Logical Files Random Reads.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
371 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Random update Please use speaker notes for additional information!
Introduction to Sequential Files. COBOL's forte  COBOL is generally used in situations where the volume of data to be processed is large.  These systems.
Submitting Instructions on web site CS 1024 students Read guide
Any Questions?.
Chapter 3 The DATA DIVISION.
Structured COBOL Programming
Indexed File Processing
CHAPTER 17 The Report Writer Module
Date Conversion Program
Presentation transcript:

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!