I have written few records in KSDS and want to fetch those records based on the Alternate key with duplicate. I am populating a value for alternate key which is present in the Vsam and reading the vsam for this key, but it satified the invalid key condition. The Return Codes & File status is 00.
Alternate key and tried reading the file. But it didnt work.
DEFINE CLUSTER(NAME(TEST.KSDS) -
Cobol Code is:
In File Control of Environment Division.
SELECT OUTFILE ASSIGN TO OUTFL
FILE STATUS IS WS-OUTFILE-STATUS
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS OT-C-ID
ALTERNATE RECORD KEY IS OT-C-NAME WITH DUPLICATES.
In procedure division
MOVE WS-NAME TO OT-C-NAME.
MOVE "Y" TO WS-FLAG.
OPEN INPUT OUTFILE.
DISPLAY "ENTER NAME TO VIEW : " OT-C-NAME.
START OUTFILE KEY IS EQUAL TO OT-C-NAME
DISPLAY "INVALID KEY!"
NOT INVALID KEY
DISPLAY "RECORD IS NOT FOUND !"
NOT INVALID KEY
DISPLAY "NUMBER : " OT-C-ID
DISPLAY "NAME : " OT-C-NAME.
DISPLAY 'READ STATUS IS:' WS-OUTFILE-STATUS.
What is happening here is. The START NOT invalid check is satisfied the goes to READ-OT-PARA and display Record not found. The Return Codes & File status is 00.
My Input Rec:
To avoid misunderstanding. FYI:
The first five rec of My Input recs are the records which were written initially and the last i.e 6th rec i.e "RAVI3" is the Alternate index with which i want to fetch records.
Just taking a guess, a keyed file in dynamic mode with a read without a next and a key, defaults to the primary key which did not have a valid value.
You might try and remove the next, move a known value into the primary key - not for the same record - and see if you get that one back.....
Start your adventure here: READ statement