Module 7: CICS Temporary Storage and Transient Data
READQ TD
The READQ TD command takes records off a transient data queue, one at a time, in order. It is the "receive" side: triggered print tasks and message processors live on this command.
Syntax and options
- QUEUE or QNAME - the symbolic destination name of the TD queue.
- INTO - the data area where CICS puts the record.
- LENGTH - a field that CICS sets to the actual length of the record read.
- There is no ITEM and no NEXT option: TD reads are always sequential, always the next record.
Destructive reads and QZERO
- Each READQ TD removes the record from the queue. Once read, it cannot be read again by any task.
- When the queue is empty, CICS raises the QZERO condition instead of returning data.
- A triggered task should loop READQ TD until QZERO, then end. QZERO also resets trigger processing so the next trigger can fire.
- Use the ASSIGN QNAME command to learn which queue started the task, so one program can serve many queues.
Reading extrapartition queues
- An extrapartition queue must be opened for input before reading.
- Reads return records in the order they were written to the data set.
- End of data set also surfaces as QZERO, so the same loop-until-QZERO pattern works.
Example:-
WORKING-STORAGE SECTION.
01 QID PIC X(4).
01 INAREA PIC X(132).
01 INLNG PIC S9(4) COMP.
01 RESPONSE PIC S9(8) COMP.
PROCEDURE DIVISION.
EXEC CICS ASSIGN QNAME(QID) END-EXEC.
READ-LOOP.
EXEC CICS
READQ TD QUEUE(QID)
INTO(INAREA)
LENGTH(INLNG)
RESP(RESPONSE)
END-EXEC.
IF RESPONSE = DFHRESP(QZERO)
EXEC CICS RETURN END-EXEC
END-IF.
IF RESPONSE NOT = DFHRESP(NORMAL)
PERFORM 9999-HANDLE-TD-ERROR
END-IF.
PERFORM 2000-PRINT-ONE-LINE.
GO TO READ-LOOP.
