What it means
ITEMERR comes from temporary storage commands. On READQ TS it means the item number does not exist or a NEXT read went past the end of the queue.
Programs that read a queue in a loop often use ITEMERR as the end-of-queue signal.
Typical causes
- Reading item n when the queue has fewer items.
- Reading with NEXT after the last item has already been read.
- Wrong item number kept in working storage or the COMMAREA.
How to fix it
- Treat ITEMERR on a NEXT read as the end of the queue.
- Check the item number before reading.
- Code RESP (and RESP2) on the command and test the value with DFHRESP.
Example
Illustrative only; names and values are invented.
EXEC CICS READQ TS QUEUE('TSQ1') INTO(WS-ITEM) NEXT
RESP(WS-RESP) END-EXEC
IF WS-RESP = DFHRESP(ITEMERR) => end of queue