Understanding VSAM: A Comprehensive Overview for Assembler Programmers

Slide Note
Embed
Share

VSAM (Virtual Storage Access Method) is a crucial component in mainframe programming, offering various file types like ESDS, RRDS, and KSDS. VSAM data sets are organized into clusters, control areas, and control intervals for efficient data management. Control intervals and areas are dynamically managed to optimize data storage. Additionally, IBM's Access Method Services (AMS) utility provides essential functions for VSAM file management.


Uploaded on Jul 23, 2024 | 3 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to VSAM for Assembler Programmers

  2. Some important VSAM file types ESDS Entry Sequenced Data Set Allows sequential processing RRDS Relative Record Data Set Allows sequential or random access by relative record number KSDS Key-Sequenced Data Set Allows sequential, skip sequential, and random processing by key The most frequently used of the three file types

  3. VSAM VSAM data sets are known as Clusters For ESDS or RRDS the cluster consists of a data component For KSDS the cluster consists of a data component and an index component VSAM data is stored on DASD in control intervals which are grouped into control areas

  4. CIs and CAs Control Area FREE FREE Control Intervals FREE . . . FREE CI FREE CI

  5. VSAM The Control Interval (CI) is the unit of data that transfers between the disk and virtual storage CI sizes are multiples of 2K with 4k being common CI s can be constructed with free space to accommodate additions to the file Control Areas (CA) can be constructed with free space to accommodate additions

  6. VSAM VSAM dynamically manages the file by maintaining information in each CI and CA When a CI becomes too full the data it contains is split into two CI s When a CA becomes too full the data it contains is split into two CA s VSAM tries to keep records that are logically close together, physically close as well

  7. KSDS INDEX Record keys IBM IMAGE: https://www.ibm.com/docs/en/zos/2.3.0?topic=index- levels

  8. VSAM Components

  9. Access Method Services (AMS) AMS is a VSAM utility that provides numerous options DEFINE CLUSTER PRINT REPRO LISTCAT DELETE DEFINE ALTERNATEINDEX DEFINE PATH BLDINDEX

  10. VSAM JCL Unlike QSAM files, VSAM files are usually allocated in a separate job step before data can be written to the file A VSAM cluster is usually created by deleting and then defining the cluster After the cluster is defined, a job can run which writes data to the file

  11. VSAM JCL Parameters: INDEXED KSDS NONINDEXED ESDS NUMBERED RRDS KEYS ( len off) primary key info CISZ (size) control interval size FREESPACE (ci ca) free space % s

  12. MAKEKSDS 000100 //TSYSAD2C JOB 'YOUR NAME',USER=TSYSAD2,REGION=2048K,MSGCLASS=V 000200 //*MAIN CLASS=TSYSC,USER=TSYSAD2 000300 //DEFINE EXEC PGM=IDCAMS 000400 //SYSPRINT DD SYSOUT=* 000500 //SYSIN DD * 000600 DELETE TSYSAD2.PAYROLL.MASTER 000700 DEFINE CLUSTER - 000800 (NAME(TSYSAD2.PAYROLL.MASTER) - 000900 INDEXED - 001000 RECORDSIZE(31 31) - 001100 KEYS(5 0) - 001200 MGMTCLAS(STANDARD) - 001210 FREESPACE(0 0) - 001220 SHAREOPTIONS (3 3)) - 001230 DATA (NAME(TSYSAD2.PAYROLL.MASTER.DATA) - 001240 TRK(1 1) - 001250 CONTROLINTERVALSIZE(4096)) - 001260 INDEX (NAME(TSYSAD2.PAYROLL.MASTER.INDEX) - 001270 TRK(1 1)) 001280 /*

  13. IDCAMS PRINT 000100 //TSYSAD2P JOB 'A.STUDENT',USER=TSYSAD2,REGION=2048K,MSGCLASS=V 000200 //*MAIN CLASS=TSYSC,USER=TSYSAD2 000210 //* THIS IS AN IDCAMS PRINT 000220 //PRINT EXEC PGM=IDCAMS 000230 //SYSPRINT DD SYSOUT=* 000240 //SYSIN DD * 000250 PRINT INFILE(IFILE) - 000251 DUMP 000252 /* 000253 //IFILE DD DSN=TSYSAD2.PAYROLL.MASTER,DISP=SHR 000254 //

  14. IDCAMS REPRO 000100 //TSYSAD2R JOB 'A.STUDENT',USER=TSYSAD2,REGION=2048K,MSGCLASS=V 000200 //*MAIN CLASS=TSYSC,USER=TSYSAD2 000210 //* THIS AN IDCAMS REPRO 000220 //REPRO EXEC PGM=IDCAMS 000230 //FILEIN DD DSN=TSYSAD2.PGM1.RESULTS,DISP=SHR 000240 //FILEOUT DD DSN=TSYSAD2.I10.PGM1.RESULTS,DISP=(NEW,CATLG,DELETE), 000250 // UNIT=SYSDA,DCB=(RECFM=FB,LRECL=80), 000251 // SPACE=(TRK,(1,1),RLSE) 000252 //SYSIN DD * 000253 REPRO - 000254 INFILE(FILEIN) - 000255 OUTFILE(FILEOUT) 000256 /* 000257 //AMSDUMP DD SYSOUT=* 000258 //

  15. VSAM Assembler Macros Two types: 1) Control Block used to define control blocks that contain information about the dataset 2) Request used to retrieve, update, delete, or insert logical records These macros reside in the main system macro library, SYS1.MACLIB

  16. Some basic VSAM control block macros ACB (Access Method Control Block) - used to create the control block that represents the VSAM file RPL (Request Parameter List) used to create a control block that describes a type of request that will be made on the file EXLST (Exit List) used to used to specify the addresses of special processing routines (like end of file)

  17. Example ACB, RPL, EXLST FILEOUT ACB AM=VSAM, MACRF=(KEY,SEQ,RST,OUT), DDNAME=FILEOUT, EXLST=FILEOEX WRTREQ RPL AM=VSAM, ACB=FILEOUT, AREA=RECOUT, RECLEN=80, OPTCD=(KEY,SEQ,NUP,MVE) FILEOEX EXLST AM=VSAM, SYNAD=SYNADERR, LERAD=LOGICERR

  18. Some basic VSAM request macros OPEN - used to open a dataset CLOSE used to close a dataset GET used to retrieve a record PUT used to write a record MODCB used to dynamically modify a control block (ACB or RPL) SHOWCB used to retrieve information from a control block POINT position ourselves in a dataset there are more!

  19. VSAM Error Strategy VSAM provides a return code in register 15 after every VSAM operation. You can check the return code after any VSAM operation to insure that the program is proceeding normally. Programmers can use their discretion about testing return codes

  20. Opening a VSAM File OPEN (FILEOUT,(OUTPUT)) A VSAM OUTPUT FILE LTR R15,R15 DID THE KSDS OPEN? JNZ BADOPEN IF NOT, QUIT VSAM ignores options like INPUT and OUTPUT for ACBs

  21. Sequentially Writing to a KSDS (Move mode) FILEOUT ACB AM=VSAM, MACRF=(KEY,SEQ,RST,OUT), MVC RECAREA,SOMEDATA PUT RPL=WRTREQ LTR R15,R15 JNZ BADWRT The record to be written is named in the RPL Initialize record with data Issue the PUT Testing R15 is optional DDNAME=FILEOUT, EXLST=FILEOEX WRTREQ RPL AM=VSAM, ACB=FILEOUT, AREA=RECAREA, AREALEN=80 OPTCD=(KEY,SEQ,NUP,MVE) FILEOEX EXLST AM=VSAM, SYNAD=SYNADERR, LERAD=LOGICERR

  22. Sequentially Writing to a KSDS (Locate mode) FILEOUT ACB AM=VSAM, MACRF=(KEY,SEQ,RST,OUT), PUT RPL=WRTREQ L R9,RECADR MVC 0(80,R9),DATA1 DDNAME=FILEOUT, EXLST=FILEOEX WRTREQ RPL AM=VSAM, ACB=FILEOUT, Address of record stored in RECADR RECADR is a fullword Addressability to record established with R9 Testing R15 after the PUT is omitted (a choice) AREA=RECADR, AREALEN=4 OPTCD=(KEY,SEQ,NUP,LOC) FILEOEX EXLST AM=VSAM, SYNAD=SYNADERR, LERAD=LOGICERR

  23. Sequentially Read a KSDS (Locate mode) FILEIN ACB AM=VSAM, MACRF=(KEY,SEQ,IN), GET RPL=RDREQ L R7,RECADR USING RECSECT,R7 Address of record stored in RECADDR The record area is indicated in the RPL Testing R15 after the GET is omitted (a choice) DDNAME=FILEIN, EXLST=FILEINEX RDREQ RPL AM=VSAM, ACB=FILEIN, AREA=RECADR,AREALEN=4, OPTCD=(KEY,SEQ,NUP,LOC) FILEINEX EXLST AM=VSAM, EODAD=DONE1 RECADR DS F

  24. Sequentially Read a KSDS (Move mode) FILEIN ACB AM=VSAM, MACRF=(KEY,SEQ,IN), GET RPL=RDREQ LTR R15,R15 JNZ BADGET PUT FILEOUT,RECAREA Record appears in RECAREA The record area is indicated in the RPL R15 return code is examined (a choice) Branch to DONE1 occurs if EOF DDNAME=FILEIN, EXLST=FILEINEX RDREQ RPL AM=VSAM, ACB=FILEIN, AREA=RECAREA,AREALEN=80, OPTCD=(KEY,SEQ,NUP,MVE) FILEINEX EXLST AM=VSAM, EODAD=DONE1 RECAREA DS CL80

  25. Modifying a Control Block FILEOUT ACB AM=VSAM, MACRF=(KEY,SEQ,RST,OUT), MODCB RPL=WRTREQ,AREA=(R7) PUT RPL=WRTREQ LTR R15,R15 JNZ BADPUT DDNAME=FILEOUT, EXLST=FILEOEX WRTREQ RPL AM=VSAM, ACB=FILEOUT, RECLEN=80, The record area is dynamically changed to R7 R15 return code is examined (a choice) OPTCD=(KEY,SEQ,NUP,MVE) FILEOEX EXLST AM=VSAM, SYNAD=SYNADERR, LERAD=LOGICERR

  26. Keyed Direct Retrieval INPUT ACB MACRF=(KEY,DIR,IN) MVC KEYAREA,=C 12345 GET RPL=RETRVE LTR R15,R15 JNZ NOTFND PUT FILEOUT,INREC Move a value to the key field Issue move mode direct read R15 return code is examined (a choice) RETRVE RPL ACB=INPUT, AREA=INREC, AREALEN=80, OPTCD=(KEY,DIR,NUP,MVE), ARG=KEYAREA, KEYLEN=5

Related


More Related Content