Page 1 of 1

Alternate Key on two different fields for VSAM files

PostPosted: Tue Aug 10, 2010 2:50 pm
by isai_22
Hi

I want to create alternate Key on two different fields for VSAM files. I dont have an idea of how to do it. Can some one help me to find a solution.

The file structure is
01 EMPLOYEE-REC.
05 EMP-ID PIC 9(6).
05 EMP-FIRSTNAME PIC A(20).
05 EMP-LASTNAME PIC A(20).
05 DESIG PIC X(20).
05 FILLER PIC X(14).

EMP-ID is primary key in original file.
The following is an example for creating alternate index on one field(firstname) which i have done.
Please help to create an alternate index on both firstname and desig fields simultaneously....


DEFINE AIX(NAME(IGTRN05.ISAI.ALTKSDS) -
RELATE(IGTRN05.ISAI.KSDS22)-
TRACKS(10 20) -
CONTROLINTERVALSIZE(10) -
FREESPACE(10 20) -
VOLUMES(USER07) -
NONUNIQUEKEY -
UPGRADE -
KEYS(20 06) -
RECORDSIZE(80 80) -
SHAREOPTIONS(1 ) -
) -
DATA (NAME(IGTRN05.ISAI.ALTKSDS.DATA) -
) -
INDEX (NAME(IGTRN05.ISAI.ALTKSDS.INDEX) -
)


Thanks :)

Re: Alternate Key on two different fields for VSAM files

PostPosted: Tue Aug 10, 2010 3:07 pm
by Robert Sample
From the manual: on DEFINE ALTERNATEINDEX
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).

length offset
Gives the length of the alternate key, in bytes, and its displacement from the beginning of the base cluster's data record, in bytes.
So the manual is telling you that what you want to do cannot be done. Either rethink your approach, create two separate alternate indexes, or add a field at the end of the record that has the data you want to create the combined alternate index on and use that field.