Simple Mainframe Universe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

CICS Troubleshooting


LENGERR on file or program command

CICS file-control problems — NOTOPEN, NOTFND, DUPREC, LENGERR, INVREQ — each RESP code points at a specific mistake.

What it means

  • Every EXEC CICS file command returns RESP/RESP2; the code names the exact problem.
  • Ignoring RESP turns clear errors into mystery abends.

Common causes

  • File not open (NOTOPEN) — closed after an error or by operations.
  • Key not found (NOTFND) — bad key value.
  • Duplicate on WRITE (DUPREC).
  • Length mismatch (LENGERR) — INTO area too small.
  • Invalid request (INVREQ) — wrong command/option combination.

How to diagnose

  • Log RESP and RESP2 at every file command.
  • Check file status: CEMT INQUIRE FILE(name).
  • Verify key and record lengths.

How to fix it

  • Open/enable the file once the cause is resolved.
  • Correct keys and lengths.
  • Handle each RESP as a business case, not an abend.

Example: Check RESP on every file command

EXEC CICS READ FILE('CUSTFILE') INTO(WS-REC) RIDFLD(WS-KEY) RESP(WS-RESP) RESP2(WS-R2) END-EXEC. EVALUATE WS-RESP WHEN DFHRESP(NORMAL) CONTINUE WHEN DFHRESP(NOTFND) PERFORM 9000-NOT-FOUND WHEN OTHER PERFORM 9000-FILE-ERROR END-EVALUATE.

RESP/RESP2 turn file errors into handled branches.

Interview tip

  • Q: How would you troubleshoot a LENGERR on file or program command in production?
  • A: I would capture the exact RESP/RESP2, check the file state with CEMT, verify keys and lengths, and fix the specific condition.

Prevention checklist

  • RESP on every file command.
  • Monitor file open/closed states.




© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant