Can we do partial key generic read in a VSAM file?

Virtual Storage Access method - ESDS, KSDS, RRDS & LDS. Basic direct access method, Basic sequential -, Queued sequential -, Basic partitioned -, Indexed sequential -, Object - access method.
Post Reply
Arun Mani
New Member
Posts: 7
Joined: Tue May 06, 2014 4:06 pm

Can we do partial key generic read in a VSAM file?

Post by Arun Mani »

Hi,

For one of the requirements I'm supposed to read a VSAM file with a partial key only. Can you please give me some pointers about this as I'm not sure if can do this.

Thanks and Regards,
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we do partial key generic read in a VSAM file?

Post by Robert Sample »

Your post is very lacking in details -- such as which language you want to use and where the partial key you wan to use starts. As long as the partial key you want to use consists of the start of the key, what you want to do is possible. If you want to read a partial key that does not start with the first byte of the key, then what you want to do is not possible.

With COBOL, you would issue a

Code: Select all

START <file name> KEY IS NOT LESS THAN <variable name> 
command on the partial key and then do a READ NEXT to retrieve the first record. Depending upon the specifics of the key, it may be possible to use spaces for the part of the key you do not have a value for, or you may need to have LOW-VALUES in that part of the key.
Arun Mani
New Member
Posts: 7
Joined: Tue May 06, 2014 4:06 pm

Re: Can we do partial key generic read in a VSAM file?

Post by Arun Mani »

Thanks Robert.

I'm might sound badly wrong but for partial key is there some restriction of knowing "left" or "right" part of the key? I'm trying to search on it and I think I got the idea from a discussion with friend but I've confused so badly that my google searches did not really return me somehitng on these lines... :?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we do partial key generic read in a VSAM file?

Post by Robert Sample »

A generic key read MUST start with the first byte of the key (the leftmost byte if you want) and contains some number of bytes of the key (at most, however, 1 byte less than the length of the key). If you want to do a generic key read of the 7th through 15th bytes of the key, for example, that is not possible since it does not start with the leftmost (first) byte of the key. It would be possible to do a read by defining an alternate index on those bytes and using the alternate index for the read -- but that is not a generic key read and not what was asked.
Arun Mani
New Member
Posts: 7
Joined: Tue May 06, 2014 4:06 pm

Re: Can we do partial key generic read in a VSAM file?

Post by Arun Mani »

Thanks Robert. This is useful information.

So if we've a partial key and it does not start from left most byte, we would use AIX, is this a correct learning?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we do partial key generic read in a VSAM file?

Post by Robert Sample »

Yes, the only way to do this would be to define an alternate index on the part of the key you want to read, then use the alternate index instead of the primary key. Depending upon the precise circumstances, the alternate index may have to allow for duplicate keys -- primary keys have to be unique but partial keys do not.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SMS & VSAM and BDAM, BSAM, QSAM, BPAM, ISAM, OAM.”