Module 7: CICS Temporary Storage and Transient Data
Temporary Storage (TS)
Temporary Storage, or TS, is the scratch-pad area CICS gives your programs. It is a place to keep data that lives longer than one task, but that you do not want to keep in a permanent file.
What is Temporary Storage
- Temporary storage is a facility where CICS application programs can store data for a short time, between tasks or between programs.
- Data in temporary storage is divided into one or more temporary storage queues, called TS queues. You access the data by queue name.
- TS data survives after the task that created it ends, so a later task can read what an earlier task wrote.
- Think of it like a work file on a desk: any program in the CICS region can put papers on it and pick them up later by name.
What a TS queue holds
- Each TS queue contains one or more records, called items.
- Every item written to a queue gets a sequential item number, starting with item number 1. The item number is not part of the record itself.
- You only need the item number when you want to retrieve or update a specific record.
- A queue can hold a single record, like one customer record, or many records, like the line items of many invoices.
The TS control commands
- WRITEQ TS - adds a new record to a queue, or updates an existing record when you code ITEM with REWRITE.
- READQ TS - retrieves a record from a queue, either randomly by item number or the next record in sequence.
- DELETEQ TS - deletes a whole queue when you are finished with it. You cannot delete single records.
- The TS keyword can be left out: if you omit the TD keyword, CICS assumes the command is for temporary storage.
Where the data is kept
- TS queues can live in main storage, which is fast but uses region memory, or in auxiliary storage, which is the VSAM file DFHTEMP on disk.
- You choose with the MAIN or AUXILIARY option on the WRITEQ TS command.
- If you write to a queue that does not exist yet, CICS creates it for you automatically.
Example:-
WORKING-STORAGE SECTION.
01 WS-SCRATCH-AREA PIC X(120).
01 RESPONSE-CODE PIC S9(8) COMP.
PROCEDURE DIVISION.
MOVE 'ORDER 4782 - PRIORITY SHIP' TO WS-SCRATCH-AREA.
EXEC CICS
WRITEQ TS QUEUE('SCRATCH')
FROM(WS-SCRATCH-AREA)
RESP(RESPONSE-CODE)
END-EXEC.
EXEC CICS
READQ TS QUEUE('SCRATCH')
INTO(WS-SCRATCH-AREA)
ITEM(1)
RESP(RESPONSE-CODE)
END-EXEC.
