i meet a problem with aix, i intend to read a ksds file through alternate key and print it out.
the compile is ok,and the run jcl as below:
//STER1 EXEC PGM=USEAIX
//STEPLIB DD DSN=userid.LIB.LOAD,DISP=SHR
//TRANS DD DSN=userid.TRANS.KSDS,DISP=SHR
[userid.TRANS.KSDS (it is cluster)]
when i ran this, rc=0, but file status code is 35,which means "then program attempted to open a nonexistent file in i-o,input,or extend mode" ,and no record display.
but i try this code,change to use primary key, the same jcl ,it works fine. pls help check the problem,.thanks!
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TRANS ASSIGN TO TRANS
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS ID-NUM1
ALTERNATE KEY IS ID-NUM2
WITH DUPLICATES
FILE STATUS IS STATUS-FIELD.
DATA DIVISION.
FILE SECTION.
FD TRANS
RECORD CONTAINS 80 CHARACTERS.
01 TRANS-FILE.
05 ID-NUM1 PIC XXX.
05 ID-NUM2 PIC XX .
05 OTHERS PIC X(75).
WORKING-STORAGE SECTION.
01 STATUS-FIELD PIC XX.
01 FILE-RECORDS PIC X(80).
PROCEDURE DIVISION.
OPEN INPUT TRANS.
DISPLAY STATUS-FIELD.
MOVE "12" TO ID-NUM2.
READ TRANS INTO FILE-RECORDS
KEY IS ID-NUM2
INVALID KEY
DISPLAY "KEY NOT FOUND".
DISPLAY FILE-RECORDS.
CLOSE TRANS.
STOP RUN.
FILE-CONTROL.
SELECT TRANS ASSIGN TO TRANS
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS ID-NUM1
ALTERNATE KEY IS ID-NUM2
WITH DUPLICATES
FILE STATUS IS STATUS-FIELD.
DATA DIVISION.
FILE SECTION.
FD TRANS
RECORD CONTAINS 80 CHARACTERS.
01 TRANS-FILE.
05 ID-NUM1 PIC XXX.
05 ID-NUM2 PIC XX .
05 OTHERS PIC X(75).
WORKING-STORAGE SECTION.
01 STATUS-FIELD PIC XX.
01 FILE-RECORDS PIC X(80).
PROCEDURE DIVISION.
OPEN INPUT TRANS.
DISPLAY STATUS-FIELD.
MOVE "12" TO ID-NUM2.
READ TRANS INTO FILE-RECORDS
KEY IS ID-NUM2
INVALID KEY
DISPLAY "KEY NOT FOUND".
DISPLAY FILE-RECORDS.
CLOSE TRANS.
STOP RUN.