Queues


Queues are designed to transfer large amounts of data between application programs or transactions, typically handling data that exceeds 32K or 64K in length. They can move data between transactions within the same region or across different regions. Additionally, queues are categorized into two types based on their behavior and usage -

  • Temporary Storage Queue
  • Transient Data Queue

Temporary Storage Queue -


Temporary Storage Queues (TSQs) are used for sharing data across transactions within a CICS region by simply using their names. TSQs contain items, which are like logical records, that are stored in temporary storage. TSQs are mostly used in implementing page-up and page-down logic and passing large amounts of data between different phases of a transaction, etc. Each TSQ can hold multiple items, which can be accessed by their assigned item numbers (e.g., 1st item, 2nd item, 3rd item, etc.).

Points to note -

  • Naming - TSQ names can be up to 16 characters long and consist of a combination of alphanumeric characters. Typically, the TSQ name is created by combining the program name (the first half) with the timestamp (the second half) of execution. For example: CICSPROG11060309.
  • Definition - There is no need to predefine TSQ anywhere. If you want a TSQ to be recoverable, it should be declared as such in Temporary Storage Tables (TST).
  • Storage - By default, TSQ is stored on main memory and cannot be defined as recoverable, while a TSQ in auxiliary memory can be.
  • Read - TSQ can read either sequentially or directly by their item number (ITEM option). Read is not destructive.
  • Write - Application programs create the TSQ by issuing a WRITE TSQNAME command. Item in a TSQ can be modified with the REWRITE option.
  • Delete - We are unable to delete individual items from the TSQ; we must delete the entire queue. Deleting the queue removes all its records. The deletion of a recoverable TSQ should occur after a SYNCPOINT before the next WRITEQ.
  • Memory Usage - Main memory is preferable for short-term TSQs, while auxiliary memory is better suited for long-term or recoverable TSQs.

Advantages -

  • One advantage of TSQs is that they do not create data until it is needed, allowing for deletion whenever the data is no longer required.
  • They are particularly suitable for handling high-volume data as well as data that varies in length or duration.
  • TSQs remain in storage until they are deleted by the task that created them, by another task, or until the region is restarted.

Disadvantages -

  • TSQs require more CPU power compared to other methods of transferring data between programs.

TSQ Commands -

Below operations can be performed on TSQs –

Command Description
WRITEQ TS Write data into TSQ
READQ TS Read data from the TSQ
DELETEQ TS Deletes all the data and the entire TSQ

Transient Data Queue -


Transient data queues are used for sharing data within a CICS region or from a CICS region to an external destination. TDQs are often used for generating reports, transferring data between CICS and batch processing, as well as managing printer spooling.

Points to note -

  • Definition & naming - TDQs must be defined in the Destination Control Table (DCT) before they can be used.
  • Storage - Transient data queues are always written to a data set.
  • Read - TDQs can read sequentially. TDQs are read-destructive. When an item is read from a TDQ, it is deleted and cannot be accessed in the future.
  • Update - Items in a TDQ can't be updated.
  • Delete - We are unable to delete individual items from the TDQ; we must delete the entire queue. Deleting (DELETEQ) the queue removes all its records.
  • Automatic Task Initiation: TDQ can trigger a transaction when the number of records in the queue exceeds the TRIGLEV defined in the DCT entry. The transaction coded in the TRANSID of DCT is automatically triggered.

Types -

There are two types of TDQ’s based on its usage -

  • Intra-partition TDQ
  • Extra-partiition TDQ

Intra-partition TDQ -


TDQs are intrapartition if they are associated with the CICS region locally. Intrapartition TDQs can be used by other programs running as separate tasks within the same CICS region.

Points to note -

  • Intrapartition TDQ must consist of variable-length records.
  • Intrapartition queues can be associated with a terminal or an output data set.
  • There are three types of Intra partition TDQs based on its nature -
    • Non-recoverable
    • Physically recoverable
    • Logically recoverable

Extra-partition TDQ -


Transient data queues are extra partitions when data is transferred to an external destination from the CICS region. The external destination could be another CICS region, a batch system, a printer, or other options.

Points to note -

  • Extrapartition queues exist on any sequential device (DASD, tape, printer, etc.) that can be accessed by programs outside of the CICS region.
  • Extra partition TDQ is not read destructive.
  • Extra partition data consists of fixed-length or variable-length records, blocked or unblocked.
  • The queue definition provides the logical organization of records that are in the queue.

TDQ Commands -

Below operations can be performed on TDQs –

Command Description
WRITEQ TD Write data to the TDQ
READQ TD Reads and deletes data from the TDQ
DELETEQ TD Deletes all the data and the entire TDQ