Module 7: CICS Temporary Storage and Transient Data
READQ TS
The READQ TS command gets records back out of a temporary storage queue. You can fetch one exact record by its item number, or walk through the queue in order.
Syntax and options
- QUEUE or QNAME - the name of the TS queue that holds the data.
- INTO - the data area where CICS puts the record it reads.
- ITEM - the item number of the record to read, for random access. The item number can be a data name or a literal.
- NEXT - reads the next record in sequence instead of a numbered one.
- NUMITEMS - a field where CICS puts the number of records currently in the queue.
Reading randomly by item number
- Give the ITEM option with the item number, and CICS returns exactly that record.
- Random reads do not disturb the sequential position, so they are safe when other tasks use NEXT on the same queue.
- If the item number does not exist, CICS raises the ITEMERR condition.
- A scratch-pad pattern uses one item only: always read ITEM(1).
Reading sequentially with NEXT
- Omit ITEM and code NEXT to get the next record in sequence, starting from where the queue was last positioned.
- Reading a record does not remove it; the record stays in the queue and can be read again.
- The sequential position is shared across tasks, so any task can move it. If that matters, reserve the queue with ENQ.
- If the queue does not exist at all, CICS raises the QIDERR condition.
Example:-
*--- Read item 1 randomly ---*
EXEC CICS
READQ TS QUEUE(TS-QUEUE-NAME)
INTO(TS-QUEUE-RECORD)
ITEM(TS-ITEM-NUMBER)
RESP(RESPONSE-CODE)
END-EXEC.
*--- Read the next record in sequence ---*
EXEC CICS
READQ TS QUEUE(TS-QUEUE-NAME)
INTO(TS-QUEUE-RECORD) NEXT
RESP(RESPONSE-CODE)
END-EXEC.
