Alternate Key on two different fields for VSAM files



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Alternate Key on two different fields for VSAM files

Postby isai_22 » Tue Aug 10, 2010 2:50 pm

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 :)
isai_22
 
Posts: 5
Joined: Mon Jul 26, 2010 8:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: Alternate Key on two different fields for VSAM files

Postby Robert Sample » Tue Aug 10, 2010 3:07 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post