CICS data management is the set of facilities that CICS applications use to store and retrieve data. The main options are: file control (for VSAM and other files), temporary storage (TSQ), transient data (TDQ), and—when configured—DB2 or other databases. Each has different persistence, sharing semantics, and access patterns. Choosing the right one depends on whether data must be permanent or temporary, shared across tasks or private, and read once or many times. This page gives an overview of these options and when to use them.
Imagine CICS as an office. Data management is all the places the office can put information: filing cabinets (files) for things that must stay forever and be looked up by name or number; sticky notes and whiteboards (temporary storage) for things you are working on right now or want to pass to the next step; and out-trays (transient data) for things you send away in order—once someone takes from the tray, that item is gone. There might also be a big database (DB2) the office shares with other departments. CICS data management is the set of rules and commands for using each of these so your program can read, write, and manage data correctly.
Every transaction that does real work needs to read or write data: customer records, orders, session state, or messages to other systems. CICS does not let programs access datasets or memory arbitrarily; they must use the supported interfaces. File Control gives structured, persistent access to files (usually VSAM). Temporary storage gives named queues that can be in memory or on a backing file, with flexible read/write and sharing. Transient data gives sequential queues that can be read-destructive (intrapartition) or sent to an external destination (extrapartition). DB2 gives SQL and relational semantics. Using the wrong facility can lead to wrong persistence (e.g. using TS when you need a file), wrong sharing (e.g. task-private when you need shared), or wrong lifecycle (e.g. TD when you need to read the same item multiple times). Understanding data management helps you pick the right tool and use it correctly.
| Resource | Purpose | When to use |
|---|---|---|
| File Control (VSAM, etc.) | Persistent, keyed or positional access to records. READ, WRITE, REWRITE, DELETE. | Master data, transactional files, shared datasets. |
| Temporary Storage (TSQ) | Named queues; main (memory) or auxiliary (backing file). WRITEQ TS, READQ TS. Can be task-private or shared. | Work-in-progress, data passed between program invocations, session-like data. |
| Transient Data (TDQ) | Queues defined in DCT. WRITEQ TD, READQ TD. Intrapartition: in-region, read-destructive. Extrapartition: to external dest (batch, printer). | Sequential message flow, triggering tasks, sending to batch or printers. |
| DB2 | Relational database access via SQL. CICS attachment coordinates units of work with syncpoint. | Structured relational data, complex queries, reporting. |
File Control is the CICS component that manages access to files. Typically these are VSAM data sets (KSDS, ESDS, RRDS) or BDAM files. Each file is defined in the File Control Table (FCT) with a logical name, the physical dataset name, file type, and allowed operations (read, update, add, browse, delete). Programs use EXEC CICS READ, WRITE, REWRITE, and DELETE with the logical file name. For updates, you must READ with UPDATE so CICS locks the record before you REWRITE or DELETE. File Control handles translation from logical name to dataset, locking, and (with CICS recovery) participation in syncpoint. For full details on READ, WRITE, REWRITE, DELETE, and the FCT, see CICS File Management.
Temporary storage provides named queues (TSQs) that can hold data during or across transactions. There are two types: main and auxiliary. Main temporary storage holds the queue data in CICS region memory; it is fast but limited in size and is lost on region failure unless the region is set up for recoverable main TS. Auxiliary temporary storage holds the queue data in a backing file (typically the VSAM data set DFHTEMP). Auxiliary TS can hold more data and can be recoverable across restarts, but each read or write involves I/O. You write with WRITEQ TS and read with READQ TS; you specify the queue name and (for READQ) the item number. Queues can be task-private (only the creating task can access them) or shared (other tasks can access by name). TS is often used for work-in-progress that must be passed from one program to the next in a transaction or from one transaction to another (e.g. session data). Use main TS for small, short-lived data; use auxiliary when data is large or must survive region restart.
12345678910111213141516* Write to temporary storage queue EXEC CICS WRITEQ TS QUEUE('MYQUEUE') FROM(WS-DATA) LENGTH(WS-LEN) ITEM(WS-ITEM) RESP(WS-RESP) END-EXEC. * Read back (e.g. in a later program) EXEC CICS READQ TS QUEUE('MYQUEUE') INTO(WS-DATA) LENGTH(WS-LEN) ITEM(WS-ITEM) RESP(WS-RESP) END-EXEC.
Transient data queues are defined in the Destination Control Table (DCT). There are two kinds: intrapartition and extrapartition. Intrapartition TDQs are used within the CICS region. Data is written with WRITEQ TD and read with READQ TD. Reading is destructive: once a record is read, it is removed from the queue and cannot be read again. Records are processed in FIFO order. Intrapartition TDQs are often used to trigger another transaction: you define a trigger level (TRIGLEV) in the DCT; when the number of records in the queue reaches that level, CICS automatically starts a specified transaction to process the queue. Extrapartition TDQs send data to an external destination: a sequential dataset, another CICS region, or a printer. Data written with WRITEQ TD goes to the destination (e.g. a batch input stream or a print file); CICS does not read it back. So intrapartition TD is for in-region, read-destructive, sequential queues; extrapartition TD is for one-way output to an external system.
| Aspect | Temporary Storage (TSQ) | Transient Data (TDQ) |
|---|---|---|
| Storage | Main: memory. Auxiliary: backing file (e.g. DFHTEMP). | Intrapartition: VSAM (e.g. DFHNTRA). Extrapartition: sequential (DASD, tape, printer). |
| Read behavior | Can read by item number; multiple readers; not destructive by default. | Intrapartition: read-destructive (record gone after read). Extrapartition: not read by CICS (data sent out). |
| Sharing | Queue can be task-private or shared across tasks (queue name). | Intrapartition: shared by queue name. Extrapartition: one writer, external consumer. |
| Typical use | Scratch area, multi-step transaction data, session data. | Triggering (TRIGLEV), report to batch, print stream. |
CICS can connect to DB2 so that CICS application programs run SQL (embedded or dynamic). The CICS-DB2 attachment coordinates the connection and allows CICS and DB2 to participate in the same unit of work. When the CICS task issues a syncpoint (e.g. normal task end or EXEC CICS SYNCPOINT), both CICS resource updates (e.g. file updates, TS) and DB2 commits are coordinated: either all commit or all roll back. This is important for consistency when a transaction updates both a VSAM file and a DB2 table. DB2 is suited to structured, relational data and complex queries; file control is often used for high-volume, keyed record access. Sites may also use other database or resource managers with CICS via similar attachment and syncpoint coordination.
CICS supports syncpoint (commit/rollback) for file updates, temporary storage (when recoverable), and DB2. When a task ends normally or issues EXEC CICS SYNCPOINT, CICS commits all recoverable changes made by that task. If the task abends or issues SYNCPOINT ROLLBACK, changes are rolled back. So data management in CICS is not only about where data lives but also about whether it participates in the unit of work. Non-recoverable resources (e.g. some TS or TD configurations) do not roll back on failure. Design your transaction so that persistent, critical updates use recoverable resources and participate in syncpoint.
1. CICS File Control is used to:
2. After reading a record from an intrapartition TDQ, the record:
3. Auxiliary temporary storage in CICS uses: