Page 1 of 1

How to randomly access the vsam file using partial key?

Posted: Tue Apr 10, 2018 12:15 pm
by alpna
Hello All,

How to randomly access the vsam file using partial key? I don't have much hands on with VSAM, can someone please help?

Re: How to randomly access the vsam file using partial key?

Posted: Tue Apr 10, 2018 3:52 pm
by nicc
What have you tried so far?

Re: How to randomly access the vsam file using partial key?

Posted: Tue Apr 10, 2018 5:21 pm
by Robert Sample
If you are accessing the VSAM KSDS data set (it is NOT a file) via the primary key, then you cannot use a partial key. However, as long as the partial key is the start of the key in COBOL you can use START to browse. If the partial key is not at the start of the key, then you must read the entire data set sequentially and compare the piece of the key you have against the record (or define an alternate key on those bytes of the primary key).

If you are accessing via an alternate index then you can use a partial key as long as the partial key is the start of the key.