VSAM ksds


KSDS Stands for ‘Key-sequenced DataSet’.

Create a KSDS Cluster

Example to define a KSDS Cluster

VSAM KSDS - Define a Cluster

To create KSDS cluster in VSAM, you can use the utility ‘IDCAMS’ where you need to define the cluster name, Data component of the cluster and details of the cluster like FREESPACE, RECSZ, TRACS, CISZ, VOLUMES etc. 

Here, we must provide the values of Keys. In this case KEYS(5,0) means length is 5 and offset is 0 which means that the key will start from a 1st character of the file with length as 5.


You can go to ‘Data Set List Utility’ to see that the cluster is created as you can see this in the above picture.

How to load records to the KSDS cluster

If you want to load the records to the cluster, you can use ‘REPRO’ command as we have used for ESDS file.

Example to load the records to the cluster

Input file from where the records will be loaded to KSDS cluster

Suppose you have a PS file whose content is as shown above which has a certain key.

In this case, the key is having offset of 0 which means that the distance from the starting position of the key is 0. This means that the key starts from the first character in the file.

The keys must be in ascending or descending order as you can see in this case.

The input file is MATEKS.TEST.PSFILE and the KSDS cluster will have records copied from this file by using the command REPRO.

Output file created

VSAM KSDS - Output KSDS file having content from ps file

You can see that the output VSAM KSDS file is ‘MATEKS.KSDS.CLUSTER’ whose content is copied from ‘MATEKS.TEST.PSFILE’

How to delete VSAM KSDS Cluster

If you want to delete VSAM cluster, then you can use the ‘DELETE’ functionality of IDCAMS

Syntax 1:

Syntax 2:

Example to delete VSAM KSDS cluster

Output cluster deleted

Tutorials for all brains!