If I want to build a alternate index for a VSAM where the Alternate Key would be from 2 to 10 bytes + then 16 to 10 bytes concatenated of Base VSAM.
Can you suggest how I need to define the alternate key parameter so that the alternate VSAM would have key as stated above + primary key of the base VSAM.Examples are typically starting and offset. Is there anyway I can acheive this.
Joined: 06 Jun 2008 Posts: 8154 Location: East Dubuque, Illinois, USA
Unload the VSAM file, move the data around so the alternate index key is contiguous and reload the VSAM file, then define your alternate index. As this quote from the Access Method Services for Catalogs manual indicates, you get one offset and one length to define your alternate index:
KEYS(length offset| 64 0)
Describes the alternate-key field in the base cluster's data record.
The key field of an alternate index is called an alternate key. The data record's alternate key can overlap or be contained entirely within another (alternate or prime) key field.
The length plus offset cannot be greater than the length of the base cluster's data record.
When the base cluster's data record spans control intervals, the record's alternate-key field is within the record's first segment (that is, in the first control interval).
Gives the length of the alternate key, in bytes, and its displacement from the beginning of the base cluster's data record, in bytes.
If you cannot define your alternate key in one contiguous field on the record, then you cannot build the alternate index -- period. Either change the file layout or give up on the alternate index idea.