- VSAM structures
- VSAM commands
- Performance tuning
- JCL Buffers
- LSR Buffers
- System Buffers
- VSAM parameters
- IAM, a VSAM alternative
- VSAM Recovery
- VSAM RLS, DFSMStvs
If you have VSAMSTAT installed, you can get basic VSAM space information by entering the line command VSAMSTAT against a VSAM component on a '3.4' ISPF listing. Results will typically look like below. The Total Free Space includes free space within the used portion of the dataset, either freespace coded for CI/CAs, or from deleted records. So Total Free Space is usually more than Allocated Space - Used Space.
Allocated Space : 30 tracks 2 Cylinders
Used Space : 15 tracks 1 Cylinders
Total Space Free : 29 tracks 1 Cylinders
Probably the most useful VSAM information command is LISTCAT. The full syntax to list out a dataset is
TSO LISTCAT ENTRY(datasetname) ALL
Most people have installed a clist to shortcut this, but if your site hasn't got one, then add a member to any clist library in your logon procedure called LC (command 'tso lista' will display your logon libraries), then inside it, put
PROC 1 MEMBER
LISTC ENT(&MEMBER) ALL
Now when you want to display the structure of a VSAM file, just use the line command 'LC' from a 3.4 file list. You will see lots of output from the command, some of which will look like
This lot is about the physical chunks in the file. It has a 18k blocksize, which fits three to a track. The CA size is 1 cylinder, so there are 45 CIs in a CA. Both the CIs and the CAs have 5% freespace reserved for growth.
Allocation information. The file is allocated in Cylinders, and has a 5 cylinder primary and a 1 cylinder secondary. It can have up to 119 extents on a single volume, and up to 255 if it can span volumes. The High-Used-Relative Byte Address is only about 800k, while the High-Allocated-Relative Byte Address is about 4m, so the file has lots of free space available for growth
Single level index, so no performance issues
How can you tell if a VSAM file is full?
Your options are to re-organise it to give it a bigger allocation, or to add candidate volumes. A reorg. is disruptive. You can add candidate volumes in flight, but you must close the file before they are picked up.
Examine is used to check that the index and data components of a KSDS are synchronised.
Typical syntax is
EXAMINE NAME(SAP.PROD.ISF04) -
INDEXTEST DATATEST -
Verify is used to check for, and fix, VSAM files which have not been closed properly after an error. The command basically adds correct End-Of-Data records to the file. Syntax is
CYL(20 20) -
VOLUMES(* * * * *)) -
These IDCAMS statements will create a new VSAM KSDS, XAB1.BATRCICS.U38, modeled on an existing KSDS, XAB1.WKLDCICS.U38, but with some attributes overridden. The new file will get a 'Month6' management class and the space allocations are changed. The dataset will be SMS managed, but the VOLUMES statement allows it to span over 5 non-specific volumes. The DATA and INDEX components are specifically named to prevent IDCAMS from allocating default names.
VSAM files often need to be initialised with high or low values before data can be added by programs. To initialise a VSAM file copy the JCL below to a PDS job library, then switch into HEX mode by typing 'HEX' on the command line, then after the INDD line type two rows of zeros as shown below. Note that x'40' is a blank space, '00' is hex low values. For high values, type in 'FF'.
000240 //INDD DD *
Type HEX OFF on the command line and you will see the JCL as below. The x'00' low values looks exactly like the x'40' blank spaces, and so does x'FF', which can be confusing. You need HEX ON to see what is really there.
//STEP0001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//INDD DD *
//OTDD DD DSN=dataset.name,DISP=OLD
//SYSIN DD *
REPRO INFILE(INDD) OUTFILE(OTDD)
The REPRO command is used to copy data between files as shown in the example above. The INFILE and OUTFILE parameters point to DD statements, and the exact file names are then placed in the JCL. In the example above, //INDD DD * means the data to be copied is placed just below this line in the JCL. You could also use
REPRO INDATASET(datasetname) OUTDATASET(datasetname)
parameters and code the file names in the SYSIN DD statement, but I prefer the DD method.
If you wanted to copy some of the data from a KSDS, you can also specify start and end keys like this
REPRO INFILE(INDD) -
REPRO can be used for VSAM backups, but EXPORT is much better as an export includes the data required to recreate a file, whereas with REPRO you need to know the file definition data so you can create it manually. Typical EXPORT commands could look like
In the first example, the dataset is copied to a file specified in the DDOUT DD statement. This could be either a disk or a tape file. Once the export in completed the original file will be deleted. In the second example, the source file is not deleted.
The data can then be recreated with an IMPORT command, and in this case, recreated with a new name.