VSAM – KEYS
Consider the below VSAM definition
DEFINE CLUSTER –
(NAME (YOUR.KYMWK15C.VSAM)) –
(NAME (YOUR.KYMWK15C.VSAM.DATA) –
CYL(500 500) –
KEYS (04 2) –
RECORDSIZE (6577 6577) –
The below data is currently available in the VSAM file.
Now when a random read on the VSAM file is done with the key value as 3456, what is the record that would be read?
KEYS give information about the prime key field of a key-sequenced data set’s data records. And the KEY is provided as KEYS (length offset) where length represents the length of the KEY field and offset represents the displacement (in bytes) from the beginning of the record.
In our question, KEYS is provided as KEYS (04 2), so the key length is 4 and the OFFSET is 2, which means that the key starts from the 3rd byte. So when we read VSAM file with keys as 3456, the record 123456KEY would be read.