Programming in COBOL-85 For IBM Mainframe System 390

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

Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store.
Introduction to C Programming
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
Processing with VSAM Files Please use speaker notes for additional information!
DB2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/DB01/003 Version No:2.0a Session Plan SPUFI Hands On Introduction to Embedded SQL DCLGEN.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Fundamentals of Python: From First Programs Through Data Structures
Structured COBOL Programming, Stern & Stern, 9th Edition
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.
15-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)
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.
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)
Programming in COBOL-85 For IBM Mainframe System 390
COBOL Programming DAY 2. Copyright © 2005, Infosys Technologies Ltd 2 ER/CORP/CRS/LA01/003 Version 1.0  Data Movement verbs.  Sequence Control verbs.
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.
Introduction to COBOL. COBOL  COBOL is an acronym which stands for Common Business Oriented Language.  The name indicates the target area of COBOL applications.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
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.
Subprograms1 THE CALL STATEMENT (chp. 16) Purpose: a calling that executes another program; allows portions of code to be treated as a “black box”. Syntax.
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
Chapter 9 I/O Streams and Data Files
VSAM Alternate Indexes Department of Computer Science Northern Illinois University August 2005.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
Chapter 9: Advanced SQL and PL/SQL Guide to Oracle 10g.
IBM-Mainframes COBOL Class-1. Background and History  COBOL is an acronym for: Common Business Oriented Language  COBOL was developed in 1959 by the.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Stored Procedures / Session 4/ 1 of 41 Session 4 Module 7: Introducing stored procedures Module 8: More about stored procedures.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
The PERFORM. The PERFORM Verb  Iteration is an important programming construct. We use iteration when we need to repeat the same instructions over and.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
VSAM ESDS and RRDS Department of Computer Science Northern Illinois University September 2005 Some of the illustrations are from VSAM: Access Method Services.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
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.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
JavaScript, Sixth Edition
Submitting Instructions on web site CS 1024 students Read guide
Programming in COBOL.
Agenda Control Flow Statements Purpose test statement
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Topics Introduction to File Input and Output
Chapter 7 Files and Exceptions
Any Questions?.
Chapter 3 The DATA DIVISION.
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
Chapter 2 - Introduction to C Programming
An Introduction to Structured Program Design in COBOL
Chapter 14 Sorting and Merging.
VHDL Discussion Subprograms
Chapter 2 - Introduction to C Programming
Agenda Collating sequence / Sorting data
VHDL Discussion Subprograms
Indexed File Processing
CHAPTER 17 The Report Writer Module
Please use speaker notes for additional information!
Using screens and adding two numbers - addda.cbl
Programming Logic and Design Fifth Edition, Comprehensive
Chapter 2 - Introduction to C Programming
Topics Introduction to File Input and Output
Programming in COBOL.
Presentation transcript:

Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Jyothis@infosys.com Phone: 52179 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Objectives of the Session (1) Index sequential file organization. (2) Relative file organization. (3) The COPY verb. (4) The CALL verb. (5) Demonstration of sample programs. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Indexed file organization Essentially comprises of two files namely (1) A data file and (2) An index file. Provides both sequential and random access. Slowest of all types of file organizations. Facilitates the use of multiple alphanumeric keys. Moderately storage efficient. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Example Data File Index File BU103 Roopa 19 BU101 Deeptha 20 REGNO NAME AGE BU103 Roopa 19 BU101 Deeptha 20 BU102 Bhavana 18 Index File REGNO ADDRESS BU101 00a3c2 BU102 00a3d4 BU103 00b943 Index 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Indexed and Relative Files 1/14/2019 9:43 AM E&R Dept., ITLInfosys

ED Entries for Indexed Files [ ] ENVIRONMEN T RANDOM DYNAMIC DIVISION . INPUT - OUTPUT SECTION FILE CONTROL SELECT LogicalFN ] FileName ASSIGN TO FileS pec ORGANIZATI ON IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS U niqueRecKe y ALTERNATE RECORD KE Y IS AltKe WITH DUPLICATES STATUS IS File Status ì í î ü ý þ ï é ë ê ù û ú 1/14/2019 9:43 AM E&R Dept., ITLInfosys

About index sequential file An indexed file in Cobol can be accessed either sequentially or randomly. When accessed randomly, the sequence in which the records are accessed can be specified by the data item called record key 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Prime key and alternate key The field which is specified in the RECORD KEY clause is known as prime key Alternate key for the file can be specified using the ALTERNATE KEY clause Alternate keys are unique by default If the file has duplicate values for the alternate key then WITH DUPLICATES phrase should be specified 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Indexed File Verbs OPEN INPUT OUTPUT I-O FileName ì í ï î ü ý þ 1/14/2019 9:43 AM E&R Dept., ITLInfosys

READ To read the records in the file in direct fashion To read the records in the file in sequential fashion 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Write and Rewrite The records are written to the logical position as determined from the value of the record key REWRITE statement requires that the file must be opened in the I-O mode 1/14/2019 9:43 AM E&R Dept., ITLInfosys

DELETE The record last read by the READ statement is deleted in case of sequential read In case of random read the record to be deleted is specified in the record key option File must be opened in the I-O mode 1/14/2019 9:43 AM E&R Dept., ITLInfosys

START statement The START positions the file to the first logical record whose record key satisfies the condition specified by the key phrase The access mode must be SEQUENTIAL OR DYNAMIC File must be opened in the I-O or input mode. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

START 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Relative Files 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Select and Assign for Relative Files

Relative File Verbs All the verbs discussed with INDEXED files holds good in Relative Organization too. Point to remember is that relative key is not part of Relative record and is declared as WS variable and must contain proper values.

File ORGANIZATIONs - A comparative study SEQUENTIAL INDEXED RELATIVE Slow when the hit Slowest Direct Access Wasteful of storage hit rate is low. organization if the file is only partially populated. Complicated to Especially slow while Complicated to change. (Insert, adding or deleting of program. Delete). records. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

File ORGANIZATIONs - A comparative study SEQUENTIAL INDEXED RELATIVE Simplest Can use multiple, Only a single, ORGANIZATION. Alphanumeric keys numeric key is allowed. Most storage Not very storage Least storage efficient. efficient. Efficient. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Demonstration of Sample Programs 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Break 1/14/2019 9:43 AM E&R Dept., ITLInfosys

COPY Verb The COPY is executed at compile time unlike other COBOL verbs which are executed at run time. The COPY statement allows programs to include frequently used source code text from a copy file or a copy library. The COPY can include source code text with or without change into the client program. Each client program which wants to use items described in the copy library uses the COPY verb to include the descriptions it requires. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

COPY Verb Examples (1) COPY “EMPLOYEE-RECORD”. (2) COPY ”STUDENT" REPLACING ABC BY XYZ. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

COPY Example IDENTIFICATION DIVISION. PROGRAM-ID. COPYEG1. AUTHOR. JYOTHI SRIDHAR. ENVIRONMENT DIVISION. FILE-CONTROL. SELECT StudentFile ASSIGN TO "STUDENTS” ORGANIZATION IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD StudentFile. COPY COPYFILE. PROCEDURE DIVISION. A0001-MAIN-PARA. -------- --------- STOP RUN. Copy member resides in OPERN.CICS3.COPYLIB 01 Student. 88 EndOfSF VALUE HIGH-VALUES. 02 StudentNumber PIC 9(7). 02 StudentName PIC X(60). 02 CourseCode PIC X(4). 02 FeesOwed PIC 9(4). 02 AmountPaid PIC 9(4)V99. 16

CALL Verb Is the most important verb that provides structured programming capabilities in COBOL. Is equivalent to a function or a sub-routine call in other computer languages. Is similar to the COPY verb, in the sense that it provides code re-usability. Provides two ways of passing parameters to the called program (1) By REFERENCE and (2) By CONTENT. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Syntax of call statement CALL NAME OF THE SUB PROGRAM USING THE PARAMETER NAMES Example CALL SUBPGM1 USING NUM1,NUM2 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Passing by reference and value CALL SUBPGM1 USING WS-NUM1. BY VALUE CALL SUBPGM1 USING BY CONTENT WS-NUM1 BY REFERENCE WS-NUM2 BY REFERENCE WS-NUM3. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Rules for coding CALLed Programs DATA DIVISION. WORKING –STORAGE SECTION. ---- LINKAGE SECTION. 01 WS-NUM1 PIC 9(3). 01 WS-NUM2 PIC 9(3). PROCEDURE DIVISION USING WS-NUM1,WS-NUM2 DATA DIVISION. WORKING –STORAGE SECTION. ---- LINKAGE SECTION. 01 WS-NUM1 PIC 9(3). 01 WS-NUM2 PIC 9(3). The CALLed programs should have a LINKAGE SECTION in the DATA DIVISION. If the CALLed programs possess WORKING-STORAGE SECTION, then the LINKAGE SECTION must appear after it. The PROCEDURE DIVISION of the CALLed program must have a USING clause to identify the variables passed from the CALLing program. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Rules for coding CALLed Programs DATA DIVISION. WORKING –STORAGE SECTION. ---- LINKAGE SECTION. 01 WS-NUM1 PIC 9(3). 01 WS-NUM2 PIC 9(3). PROCEDURE DIVISION USING WS-NUM1,WS-NUM2. A001-MAIN-PARA. ----- EXIT PROGRAM The variables defined in the LINKAGE SECTION can be defined in any order. The variables in the USING clause must be in the same order as in the CALL statement of the CALLing program. Instead of a STOP RUN statement, the CALLed program must contain an EXIT PROGRAM statement to transfer the control back to the CALLed program. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Review Index sequential file organization. Relative file organization. The COPY verb. The CALL verb. 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Review questions DELETE statement should be followed by ( file/record) _________ For updation and deletion, the files are to be opened in ___________________ mode COPY statement is allowed only in the data division ( True / false ) Indicate which of the following COBOL verb does not use FROM phrase ACCEPT DISPLAY PERFORM WRITE File name Input-output (I-O) 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Review Questions LINKAGE SECTION cannot have any value clause (True / False ) RENAMES clause cannot be used in LINKAGE SECTION (True / False ) COPY statement is executed during compile time rather then run time ( True/ False) 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Any Questions ???? 1/14/2019 9:43 AM E&R Dept., ITLInfosys

Thank you Jyothi Sridhar Kini E&R, Infosys Mail-id: Jyothis@infosys.com Phone: 52179 1/14/2019 9:43 AM E&R Dept., ITLInfosys