IBM Mainframes COBOL Training Class10 Data Sets Dataset
IBM Mainframes COBOL Training Class-10
Data. Sets § Dataset: A named collection of data in an IBM mainframe operating system. A data set in an IBM mainframe is the equivalent of a file in other operating systems § A dataset is typically stored on Direct Access Storage Disk (DASD) or magnetic tape. § These Dataset are of two types: § PDS (Partitioned Dataset ) § PS (Physical Sequential Dataset )
Partitioned Data Set & Physical Sequential Dataset § PDS or Partitioned Data Set is a dataset containing multiple partition’s each of which may contain a members § § Members are COBOL Programs, JCL Programs, Load Modules etc. § § PS or Physical Sequential Data Set is a dataset that contains records The Partitioned Data Set can only allocate on a single volume with the maximum size of 65536 tracks. Records like employee details, customer details etc. ,
DASD & Main-Memory § Direct Access Storage Disk ( DASD ) Mainframes Hard Disk which stores the physical data DASD UNITS ( SYSDA & SYSALLDA) VOLUMES DATA SETS MEMBERS/RECORDS § Main-Memory : Mainframes temporary space used by variables of an application program.
Steps to follow 1. Allocation: The files used in the program should be declared/specified in FILE-CONTROL paragraph with-in INPUT-OUTPUT SECTION of ENVIRONEMNT DIVISION. 2. Definition. The Record layout of the file and its attributes are defined in the FD PARAGRAPH with-in FILE SECTION of DATA DIVISION. 3. Open: Dataset is connected/readied to your program using OPEN statement. The mode of OPEN decides the operation allowed and the initial pointer in the dataset. 4. Process: Process the file as per requirement, using the I-O statements /FILE VERBS provided by COBOL. (READ, WRITE, REWRITE and DELETE) 5. Close: After the processing, close the file to disconnect it from the program.
Environment division § Define the file in FILE-CONTROL Paragraph of INPUT-OUTPUT SECTION with in ENVIRONMENT DIVISION. § SELECT Statement is used to define a file. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT LOGICAL-FILENAME ASSIGN TO DDNAME ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-STATUS. Organization and Access mode is optional for a PS file, the default is sequential itself
Points To Note § Number of SELECT statements specifies number of files used in a program. § Logical file name is used through out the program execution. § Must not exceed 8 characters. § Like EMPFILE, CUSTFILE, IN-FILE , OUTFILE etc. § DDNAME Acts as a link between logical and physical file name which is used in the execution JCL. § Must Not Exceed 8 Characters. § Like EMPDD, CUSTDD, IN-DD, OUT-DD ETC.
Organization and Access Mode § § Organization : The way in which records are arranged in the file. Ways of organization : § Sequential One record after other § Indexed Based on a index key value ( VSAM ) § Relative Based on a relative record number ( VSAM ) § Access mode : The way in which records can be accessed ( retrieved ) from a file. § Access mode are : - § Sequential One after other record only till end of the file § Random Access directly a record from the file § Dynamic Both direct and sequential combined
File Status Code § It is a two-byte working storage item. The first byte denotes the general category whereas second byte denotes the particular type of error message under that category. § 0 Successful OPEN/READ/WRITE Operation § 00 § 10 § 20& 90 Successful completion When AT END condition fails 10 Sequential READ is attempted after the end of file is reached § 21, 22, 23, 24 & 90, 92, 97 all these are related to VSAM. § § 30 Opening Error Like. . 39 mostly 40 Logical Error in programs
DATA DIVISION § File has to be described in FD Paragraph of FILE SECTION with in DATA DIVISION. § § File section should be the first section if coded. § Instead of record layout specifying here we mostly use COPYBOOK. Syntax: DATA DIVISION. FILE SECTION. FD LOGICAL-FILENAME LABEL RECORDS ARE STANDARD/OMMITED. 01 RECORD-LAYOUT. 05 …. . / COPYBOOK-NAME.
Open and Close § Any file operated in an application program need to be opened first and later on closed after the task completion. § Syntax : OPENING-MODE FILE 1[, FILE 2]. CLOSE FILE 1[, FILE 2].
File Opening modes § We have 4 type of opening modes. § They are : § INPUT Mode : - Can perform only read § Output Mode : - Can perform only write § I-O Mode : - Can perform read and rewrite § Extend Mode: - Can append a new record to existing file
File Operation & File Verbs To perform any operation on file we use one file verb which are listed below File verb Action Opening mode OPEN Connect to file --- CLOSE Release the file --- READ Retrieves a record INPUT/I-O WRITE Adds a new record OUTPUT/EXTEND REWRITE Update an existing record I-O DELETE Delete’s a record I-O
READ Verb § READ verb reads a single record at a time. Record fetch by read statement will be moved into the record layout, defined at FD within FILE-SECTION. File must be opened in INPUT / I-O Mode § Syntax 1. To read only one record READ FILENAME [INTO WS-RECORD-LAYOUT], § Syntax 2. To read till end of the file sequentially READ FILENAME AT END STATEMENT NOT AT END STATEMENT END-READ.
WRITE Verb § WRITE VERB is used to write a new record into the file. File must be opened in OUTPUT Mode. § The data has to be moved into the record layout before making a write statement. § Syntax : § WRITE RECORD-LAYOUT. § RECORD LAYOUT defined in FILE-SECTION along with FD § WRITE RECORD-LAYOUT FROM WS-GROUP-NAME. § WS WORKING-STORAGE SECTION data-area
REWRITE Verb § REWRITE VERB updates a specific record which is already exists in the file. File must be opened in I-O Mode. § The updated data has to be moved into the record layout before making a rewrite statement. § Syntax : § REWRITE RECORD-LAYOUT.
DELETE Verb § § Delete verb delete’s a record from the file. § Syntax : Record present in PS FILE cannot be deleted instead we move space to remove a record from the file. § DELETE FILENAME. § Deletes only one record not the file.
Sample Programs In Practical
Thank You Polsani Anil Kumar
- Slides: 19