VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services.

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

Lectures on File Management
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
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.
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.
Processing with VSAM Files Please use speaker notes for additional information!
14-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)
MVS/ESA Fundamentals of VSAM © Copyright IBM Corp., 2000, All rights reserved.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
CS 4432lecture #71 CS4432: Database Systems II Lecture #7 Professor Elke A. Rundensteiner.
Chapter 6 AN INTRODUCTION TO FILES AND FILE PROCESSING Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering.
Structured COBOL Programming, Stern & Stern, 9th Edition
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
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.
File Organization Techniques
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)
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 13 Sequential File Processing. Master Files Set of files used to store companies data in areas like payroll, inventory Usually processed by batch.
The Fun That Is File Structures Pages By: Christine Zeitschel.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
COBOL Cobol is one of the most robust language in the software field, so far Cobol turned 50, in 2009 Cobol has stood the test of time Common Business.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
10/16/ ER/CORP/CRS/OS02/003-4 JCL DAY 4. 10/16/ ER/CORP/CRS/OS02/003-4 VSAM DATASETS (virtual storage access method) These are the logical.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
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.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
Indexed Files continued. Figure 17.1 Sequential Update OLD MASTER TRANSACTION NEW MASTER ERROR MESSAGES UPDATE PROGRAM.
14- 1 Chapter 14.  To familiarize you with ◦ How files may be sorted ◦ How to process file during SORT procedure  Before it is sorted  After it is.
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
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 7 Files.
13-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)
Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
VSAM Alternate Indexes Department of Computer Science Northern Illinois University August 2005.
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.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
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.
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.
VSAM KSDS Structure and Processing Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access.
Random update Please use speaker notes for additional information!
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs.
Topics Covered: File Components of file Components of file Terms used Terms used Types of business file Types of business file Operations on file Operations.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Topics Introduction to File Input and Output
Chapter 7 Files and Exceptions
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
Chapter 14 Sorting and Merging.
Programming in COBOL-85 For IBM Mainframe System 390
Indexed File Processing
CHAPTER 17 The Report Writer Module
Please use speaker notes for additional information!
Topics Introduction to File Input and Output
Presentation transcript:

VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services and Programming Techniques by James Martin

2 Processing a KSDS KSDS can be processed 3 ways –Sequentially Records accessed in key sequence –Randomly Records accessed via a specified key value –Dynamically Records accessed both sequentially and randomly

3 Sequentially Processing a KSDS Access records in ascending order on the file’s key field Usually begin with the first record and process to the end

4 File-Control for Sequential KSDS File-Control. SELECT file-name ASSIGN to ddname ORGANIZATION is INDEXED ACCESS MODE is SEQUENTIAL RECORD KEY is data-name-1 FILE STATUS is data-name-2.

5 File-Control for Sequential KSDS File-Control. SELECT file-name where file-name is the name used for the file throughout the program

6 File-Control for Sequential KSDS File-Control. ASSIGN to ddname where ddname is the ddname in the JCL used to refer to the KSDS file

7 File-Control for Sequential KSDS File-Control. ORGANIZATION is INDEXED where INDEXED specifies that this file is a KSDS

8 File-Control for Sequential KSDS File-Control. ACCESS MODE is SEQUENTIAL where SEQUENTIAL specifies that the processing of the KSDS will be in order on the key field of the file

9 File-Control for Sequential KSDS File-Control. RECORD KEY is data-name-1 where data-name-1 is the file’s key field and the records are going to be accessed ascending on this field data-name-1 must appear in the file’s record description in the FILE SECTION

10 File-Control for Sequential KSDS File-Control. FILE STATUS is data-name-2 where data-name-2 is a filed you specify in which VSAM provides information about each I/O operation VSAM places a return code in data-name-2 for the application program to determine the result of the I/O operation

11 Common File Status for KSDS CodeMeaning 00Successful completion 10End of file reached 21Sequence error 22Duplicate key 23Record not found 24No more space

12 FD Statement in KSDS FD KSDS-file LABEL RECORDS ARE [OMITTED or STANDARD]. Treated as a comment but is required

13 Procedure Division in KSDS Sequential Processing OPEN statement START statement READ statement WRITE statement REWRITE statement DELETE statement CLOSE statement

14 KSDS OPEN Statement OPEN statement (sequentially) Must open all files –Loading sequentially OPEN OUTPUT ksds-file. –Retrieving sequentially OPEN INPUT ksds-file.

15 KSDS START Statement START statement –Used to start sequential processing with a record other than the first record in the file –Use with a file that is opened as input or dynamically (I-O) and processing sequentially –To use, place a value in the record key area

16 KSDS START Statement START statement START vsam-file [KEY IS {EQUAL TO = GREATER THAN > NOT LESS THAN NOT < GREATER THAN OR EQUAL TO >= } record-key] [INVALID KEY imperative-1] [NOT INVALID KEY imperative-2] [END-START]

17 KSDS READ Statement READ statement (sequential) –To retrieve records in key sequence, open KSDS for either INPUT or I-O

18 KSDS READ Statement READ statement (sequential) READ file-name RECORD [INTO area] [AT END imperative-1] NOT AT END imperative-2] [END-READ]

19 KSDS READ Statement READ statement (sequential) READ file-name [NEXT] Specify NEXT on the READ statement to retrieve records sequentially when file is opened for I-O Omit NEXT when file is opened for I-O and the records will be retrieved randomly based on the value in the RECORD KEY field

20 KSDS READ Statement READ statement (sequential) –The key using dynamic access is knowing how to switch from sequential to random access. –The position for sequential retrieval is changed only by a START or a random READ statement.

21 KSDS READ Statement READ statement (sequential) –A random READ statement can be used to retrieve a specific record and then can be followed by a sequential READ statement (using the NEXT option)

22 KSDS WRITE Statement WRITE statement (sequential) –KSDS must be opened for OUTPUT for file creation (loading of data) I-O for file additions –A value must be placed into the primary key field prior to the write

23 KSDS WRITE Statement WRITE statement (sequential) WRITE record-name [FROM area] [INVALID-KEY imperative-1] [NOT INVALID-KEY imperative-2] [END-WRITE]

24 KSDS WRITE Statement WRITE statement (sequential) –INVALID-KEY imperative-1 is executed when the value stored in the primary key field prior to issuing the WRITE is equal to that of a record already in the file an attempt is made to write beyond the boundaries of the file the primary key is not greater than the primary key of the previous record AND the file is opened for OUTPUT and sequential accessing is specified

25 KSDS REWRITE Statement REWRITE statement (sequential) –the KSDS must be opened for I-O –the record to be rewritten needs to be the last record read from the file must read the record prior to rewriting it

26 KSDS REWRITE Statement REWRITE statement (sequential) REWRITE record-name [FROM area] [INVALID KEY imperative-1] [NOT INVALID KEY imperative-2] [END-REWRITE]

27 KSDS REWRITE Statement REWRITE statement (sequential) –[INVALID KEY imperative-1] is executed when the record to be changed does not exist in the file sequential access is specified and the value placed in the primary key doesn’t equal the primary key fo the previously read record

28 KSDS DELETE Statement DELETE statement (sequential) –KSDS opened as I-O –delete the record read in the last READ statement –the space in KSDS is immediately available for reuse

29 KSDS DELETE Statement DELETE statement (sequential) DELETE file-record RECORD [INVALID-KEY imperative-1] [NOT INVALID-KEY imperative-2] [END-DELETE]

30 KSDS DELETE Statement DELETE statement (sequential) –[INVALID-KEY imperative-1] is executed when an attempt to delete a record that does not exist is made

31 KSDS CLOSE Statement CLOSE statement (sequential) –list the KSDS that is to be closed

32 KSDS Load Program in COBOL Go over handout “COBOL JCL & Source Review for Loading KSDS”

33 KSDS Random Processing All I/O operations depend upon the record key Before READ a value must be in the record key Before WRITE a value must be in the record key

34 File-Control for Random KSDS File-Control. SELECT file-name ASSIGN to ddname ORGANIZATION is INDEXED ACCESS MODE is RANDOM RECORD KEY is data-name-1 FILE STATUS is data-name-2.

35 File-Control for Random KSDS File-Control. ACCESS MODE is RANDOM The only difference in the SELECT statement for random processing is the word RANDOM access

36 Procedure Division in KSDS Random Processing OPEN statement READ statement WRITE statement REWRITE statement DELETE statement CLOSE statement

37 KSDS OPEN Statement OPEN statement (random) Must open all files –Retrieving randomly OPEN INPUT ksds-file. –Writing randomly OPEN OUTPUT ksds-file. –Reading, rewriting and deleting randomly OPEN I-O ksds-file.

38 KSDS READ Statement READ statement (random) –To retrieve records based upon value in the record key field, open KSDS for either INPUT or I-O

39 KSDS READ Statement READ statement (random) –To retrieve records based upon value in the record key field, open KSDS for either INPUT or I-O

40 KSDS READ Statement READ statement (random) READ file-name RECORD [INTO area] [KEY IS data-name-1] [INVALID KEY imperative-1] NOT INVALID KEY imperative-2] [END-READ]

41 KSDS READ Statement READ statement (random) [KEY IS data-name-1] The key value of the record that is to be retrieved from the KSDS must be placed in data-name-1 prior to issuing the READ statement.

42 KSDS READ Statement READ statement (random) –when invoked comparison is made between the value of the field specified in the RECORD KEY clause of the SELECT statement (known as “key of reference”) and the key values of the KSDS records –search is done via the index –appropriate control interval is read into memory and sequentially searched

43 KSDS WRITE Statement WRITE statement (random) WRITE record-name [FROM area] [INVALID-KEY imperative-1] [NOT INVALID-KEY imperative-2] [END-WRITE]

44 KSDS WRITE Statement WRITE statement (random) –used to add records to a file –KSDS uses the RECORD KEY value to write the record in its proper physical location

45 KSDS REWRITE statement REWRITE statement (random) REWRITE record-name [FROM area] [INVALID KEY imperative-1] [NOT INVALID KEY imperative-2] [END-REWRITE]

46 KSDS REWRITE statement REWRITE statement (random) –used to update a record in its original physical location –KSDS uses the RECORD KEY value to rewrite the record in its proper physical location

47 KSDS DELETE Statement DELETE statement (random) DELETE file-record RECORD [INVALID-KEY imperative-1] [NOT INVALID-KEY imperative-2] [END-DELETE]

48 KSDS DELETE Statement DELETE statement (random) –used to delete a record from its physical location –KSDS uses the RECORD KEY value to find the record to delete

49 KSDS CLOSE Statement CLOSE statement (random) –list the KSDS that is to be closed

50 KSDS Dynamic Processing Processing can be a mix of sequential and random All the statements remain the same except the SELECT and the sequential READ

51 KSDS Dynamic Processing Using dynamic processing effectively is knowing how to switch from sequential to random access –position for sequential retrieval by a START or random READ –issue READ using NEXT for sequential processing

52 KSDS Dynamic Processing Note: –During dynamic processing issuing a WRITE, REWRITE, or DELETE statement does not change file position –Use START or random READ to change file position

53 File-Control for Dynamic KSDS File-Control. SELECT file-name ASSIGN to ddname ORGANIZATION is INDEXED ACCESS MODE is DYNAMIC RECORD KEY is data-name-1 FILE STATUS is data-name-2

54 KSDS READ Statement READ statement (dynamic) READ file-name [NEXT] RECORD [INTO area] [KEY IS data-name-1] [INVALID KEY imperative-1] NOT INVALID KEY imperative-2] [END-READ]

55 KSDS READ Statement READ statement (dynamic) –NEXT is used in dynamic processing of KSDS to retrieve records sequentially on the key –if NEXT is omitted the records are retrieved randomly based on the value in the RECORD KEY field