I need to read allrecords in a VSAM file using CICS. So I used STARTBR and then READNEXT function, but I got error number 16 which means ´INVREQ: Read operation not permitted as it is not mentioned in the FCT. Record is locked ´, now I dont know how to address this error. I have tried the below code
EXEC CICS READNEXT FILE(filename)
INTO (wa-recrd)
LENGTH(length of wa-recrd)
RIDFLD (record-index)
KEYLENGTH(length of record-index)
SYSID (node-name)
RESP (ws-resp)
As in your other question, VSAM files are made available to CICS with a FILE resource definition. The dataset name can be supplied in the FILE definition or can be provided in the JCL. (If you include a DD statement for the file in the JCL, the dataset name will override one that was specified in the FILE resource definition.)
Also the FILE resource definition are the actions which may be performed against the file. The available actions are ADD, BROWSE, DELETE, READ, and UPDATE. In the scenario you describe, your file would require both BROWSE(YES) and READ(YES) on the FILE resource definition.
Note that an error 16 (INVREQ) can be caused by several conditions. You need to examine the RESP2 or EIBRESP2 values to determine exactly why your program received the INVREQ error. The best way to get this value is to simply add the RESP2 keyword to your READNEXT command.