I am creating a VSAM file with primary and alternate key. The primary starts at 1 and of length 19 and the alternate key starts at 20 and of length 11. Please find the code for the definition and usage in the program below:
SELECT MAC-CIC-VSAM-FILE ASSIGN TO DA-CICVSAM
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS CARD-NUMBER
ALTERNATE KEY IS ACCT-ACCOUNT-ID
FILE STATUS IS IO-STATUS-CODE.
The process of creating an alternate index for a VSAM file is:
1. Define the base cluster
2. Load at least one record into the base cluster
3. Build the alternate index
4. Define the path for the alternate index
Note that these steps need to be done in this order.
If you are writing a program to perform step 2, then that program does NOT reference an alternate index -- PERIOD. When you have a program that you want to use the alternate index (after step 4 above), you MUST provide the PATH name in the JCL -- if your DD name is CICVSAM, then the path would be allocated to DD name CICVSAM1.