Using temporary storage

In CICS®, temporary storage is the primary method for storing data that must be available to multiple transactions. Data items in temporary storage are placed in queues with names assigned dynamically by the program storing the data. Temporary storage is implemented in two different ways: main temporary storage and auxiliary temporary storage:
  • Main indicates that the queue is stored in space taken from the dynamic storage area.
  • Auxiliary indicates that the queue is written to an entry-sequenced VSAM data set.
Main and auxiliary storage have the following characteristics:
  • CICS® maintains an index of items in main storage.
  • Main temporary storage requires more virtual storage than does auxiliary. It should be used for small queues that have short lifetimes or are accessed frequently.
  • Auxiliary temporary storage is designed for large amounts of data that must be stored for a long time or are accessed infrequently.
  • Queues can be recovered in auxiliary temporary storage.
    Note:
    Only one transaction at a time can update a recoverable temporary storage queue. Keep in mind the probability of enqueues as you design your program. You should also ensure that there are enough VSAM strings to eliminate as much contention as possible.
  • If a task attempts to write to temporary storage and the space is not available, CICS® suspends the task. The task is not resumed until another task frees the needed space in main storage or in the VSAM data set.
  • Rational® COBOL Runtime for zSeries® uses temporary storage to save information about the program during a segmented converse or to save a copy of the form during a transfer using a show statement. You can use the workDBType build descriptor option to specify whether the main or auxiliary temporary storage is to be used.

Accessing temporary storage from EGL

An EGL program generated for the CICS® environment can access CICS® temporary storage as a serial or relative record. The following I/O statements are valid when you access temporary storage:
  • add
  • close
  • delete
  • get
  • get next
  • get forUpdate
  • replace

The resource association for the file must have the EGL file type specified as tempaux (auxiliary storage file) or tempmain (main storage file) when the program is generated. The system resource name (systemName property) is the queue name associated with the temporary storage file.

Temporary storage files can be used by only one task at a time. EGL generates the following CICS® commands for you:
  • When the queue is first accessed, EGL enqueues with a CICS® ENQ command (NOSUSPEND option) on the resource name EZETEMP-queuename.
  • When the file is closed (close statement or end of program) or when recoverable resources are committed, EGL dequeues with a CICS® DEQ command.

Non-EGL programs that access the same file should enqueue on the same system resource name while accessing the file.

Records in temporary storage have an additional byte added to the front of the record that indicates the status of the record:
X'01'
indicates that the record has been logically deleted.
X'00'
indicates that the record logically exists in the file.
The additional byte is added to the record definition and managed by Rational® COBOL Runtime for z/Series. Do not include the additional byte in the EGL record definition. However, if the temporary storage file is also used by a non-EGL program, the non-EGL program must allocate space for the byte, interpret the byte, and update it as EGL does. Processing of the additional byte is as follows:
add or replace
The byte is set to X'00'.
delete
The byte is set to X'01' and the record length is set to 1.
get next
Records with a value of X'01' are skipped.
get or get forUpdate
Records with a value of X'01' cause a noRecordFound record state to be set.
The close statement does not delete temporary storage files. Use the sysLib.purge() system function to delete the file. EGL enqueues by generating a CICS® ENQ command with the NOSUSPEND option on resource name EZETEMP-queuename when sysLib.purge() is used and dequeues (DEQ command) after the queue is deleted.