Problem:
A VSAM file is defined with 1 alternate index with no duplicates.
In DOS/VSE a program can define just the file in the program as alternate index and not define the primary index. This will allow the READ to use the alternate index with out defining the key to the READ statement.
The program files in the alternate index that exists returns a file status of 23.
A start browse and a read next using the same data returns the expected record.
INITIALIZE REC-INFO.
MOVE WS-ALTX1-DATA1 TO REC-ALTX1-DATA1.
MOVE WS-ALTX1-DATA2 TO REC-ALTX1-DATA2.
MOVE WS-ALTX1-DATA3 TO REC-ALTX1-DATA3.
READ DATA-FILE KEY IS REC-ALTX1-KEY
END-READ.
Resolution:
What was not noted above was the first change that was required to compile the DOS/VSE program within Micro Focus to get the file open to work and not get a 139 error.
An INDEX file that has one or more alternate indexes must have all indexes defiled within the file SELECT statement, so where DOS/VSE would only define the primary or alternate that they wanted to use within the program, that is currently not possible within Micro Focus COBOL.
This READ issue is documented within the READ statament and reads as follows.
If the KEY phrase is not specified the prime record key is established as the key of reference for this retrieval. If dynamic access mode is specified, this key of reference is also used for retrievals by any subsequent executions of Format 3 READ statements for the file
By adding the KEY is clause to the read it was successful
INITIALIZE REC-INFO.
MOVE WS-ALTX1-DATA1 TO REC-ALTX1-DATA1.
MOVE WS-ALTX1-DATA2 TO REC-ALTX1-DATA2.
MOVE WS-ALTX1-DATA3 TO REC-ALTX1-DATA3.
READ DATA-FILE KEY IS REC-ALTX1-KEY
END-READ.
#EnterpriseServer
#Enterprise
#COBOL
#Server
#netexpress