Skip to content
systemcoding.dev
Mainframe

What CICS Is: Transactions, Tasks and Programs Explained

CICS is IBM's transaction server for z/OS. Learn how a transaction ID starts a task that runs a program, and how regions, resources and the CSD fit.

5 min read
Summarize in AI
Flat illustration of a 3270 terminal showing JCL beside a mainframe.

CICS is the software that sits between thousands of terminals or web clients and your programs, and it answers one question at enormous volume: when someone sends a four-character code, which program runs, with whose data, and what happens if it fails? This post explains the vocabulary that every later CICS topic leans on, using CICS Transaction Server for z/OS 6.1 on z/OS 3.1. The three words to separate are transaction, task and program. They sound alike, and mixing them up is the commonest early confusion.

What CICS does

CICS Transaction Server (CICS TS) is an online transaction processing monitor. It runs as a started task, a long-lived z/OS address space called a region. Inside that region it receives requests, starts a unit of work for each one, loads the right application program, provides services such as terminal I/O, file access and queues, and ends the work cleanly or backs it out. Batch programs run once and finish. A CICS region runs all day, and its programs run for a fraction of a second each, thousands of times.

The reason CICS exists is that doing this inside every application is wasteful. A single region shares one copy of a program among hundreds of concurrent users, manages storage, serializes access to files and coordinates commits with Db2 and other resource managers.

Transaction: a name you type

A transaction is a business request identified by a transaction ID, a name of one to four characters. On a 3270 terminal you clear the screen, type ORD1 and press Enter. ORD1 is the transaction ID. CICS looks it up in a table of definitions, a TRANSACTION resource, and finds the name of the program that runs it.

The definition is small. It names the transaction, the program to start and a few attributes such as security and whether the program is expected to be threadsafe, a subject covered later in the cluster. One program can serve several transaction IDs, and each ID can carry different attributes.

Task: one running instance

A task is one execution of a transaction for one request. If twenty clerks type ORD1 at the same moment, CICS creates twenty tasks. Each task gets a unique task number, its own working storage, its own transaction work area and its own place in the dispatcher's queue. Tasks run concurrently under the control of the CICS dispatcher, which switches between them whenever one waits, for example for a disk read or a terminal response.

This is the point that makes CICS programs different from batch programs. Your program does not own the machine. It runs for a short slice, issues a command, and CICS takes control at that command. If the command has to wait, CICS runs a different task. When the data arrives your task is made ready again.

Program: the code that a task runs

A program is the compiled load module that holds your COBOL, PL/I, C or Java logic. It is defined to CICS with a PROGRAM resource that names the load module and its language. A task runs one program at a time, although a program can pass control to another with LINK or XCTL, covered in a later post.

The same program, loaded once, serves every task that needs it. That works because CICS programs are reentrant: they do not modify their own code, and every task gets its own copy of working storage. If you write a program that stores a counter in a static location shared by all tasks, you have broken the model, and the symptoms will be intermittent and ugly.

TermWhat it isExample
TransactionThe named kind of requestORD1
TaskOne running instance of a transactionTask number 04117
ProgramThe load module the task executesORDPROG1
RegionThe address space that runs it allCICSPRD1

The definitions: resources and the CSD

CICS needs to be told what exists. Each definition is a resource: a TRANSACTION, a PROGRAM, a FILE, a MAPSET and so on. The definitions are stored in a VSAM data set called the CICS system definition file, the CSD, which is edited with the CEDA transaction and installed into a running region. Resources are grouped, groups are collected in lists, and a list is loaded at startup. A later post in this cluster shows how to define and install them.

A minimal pair of definitions for our example looks like this when written in the batch utility DFHCSDUP syntax.

jcl
DEFINE PROGRAM(ORDPROG1) GROUP(ORDGRP)
       LANGUAGE(COBOL)
DEFINE TRANSACTION(ORD1) GROUP(ORDGRP)
       PROGRAM(ORDPROG1)

The first defines the program, the second the transaction that starts it. Both belong to the group ORDGRP. You can run DFHCSDUP as a batch step to create them, or define the same resources online with CEDA.

What a request looks like end to end

Put the pieces together for one request. A user types ORD1 and presses Enter. The terminal control component of CICS receives the input and reads the first four characters as the transaction ID. CICS finds the ORD1 definition, creates a task, loads ORDPROG1 if it is not already in storage and starts it. The program issues EXEC CICS commands to read a file, build a screen and send it back. When it ends with EXEC CICS RETURN, CICS releases the task and its storage, commits any recoverable changes and sends the response. The user sees a screen, and the whole sequence took a few milliseconds.

If the program abends, CICS backs out the changes made by that task, issues a message to the log and may show the user an abend code. Other tasks keep running. This isolation is a core reason the monitor exists.

Where you meet the vocabulary in practice

You see tasks when you run CEMT INQUIRE TASK, which lists each active task with its transaction ID and program. You see programs with CEMT INQUIRE PROGRAM, which shows whether each is enabled and how many times it was used. You see transactions in CEMT INQUIRE TRANSACTION. Those inquiry commands are among the first tools every CICS developer learns. A task that has been running for a long time is a clue to a loop or a lock wait, and its transaction ID tells you which application owns it.

Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.