MainframeKit

ENDFILE

DFHRESP(ENDFILE) = 20CICS RESP CONDITION

A browse reached the end of the file: there are no more records to read.

MOST LIKELY

The browse loop read every record from the start key to the end of the file.

FIRST CHECK

Test RESP after every READNEXT and leave the loop on ENDFILE.

TRY IT ▸

MainframeKit assistant

What it means

RESP 20 (RESP2 90) is raised by READNEXT when the browse runs off the end of the file. It is the normal way a browse loop finishes.

If the program does not test RESP for it, CICS ends the task abnormally.

Typical causes

  • The browse loop read every record from the start key to the end of the file.
  • The start key was past the last record, so the first READNEXT already hit the end.
  • The loop has no other stop test, such as checking when the key prefix changes.

How to fix it

  1. Test RESP after every READNEXT and leave the loop on ENDFILE.
  2. Issue ENDBR after the loop finishes.
  3. Add a stop test on the key so the loop ends before the end of file when only a range is needed.
  4. If ENDFILE comes on the first read, check the start key.

Example

Illustrative only; names and values are invented.

PERFORM UNTIL WS-RESP = DFHRESP(ENDFILE)
   EXEC CICS READNEXT FILE('ORDFILE') INTO(WS-ORD) RIDFLD(WS-KEY)
        RESP(WS-RESP) END-EXEC
END-PERFORM