Data Passing between Programs or Transactions
In a real-time environment, a single program can’t finish the task, and a series of programs are required to complete the task fully. Those series of programs/transactions require passing the input and processing data from one program/transaction to another.
This mechanism is called a Data Passing Mechanism. CICS provides multiple ways to transfer data between programs or between transactions, depending on the scope and lifetime of the data.
There are two main ways to pass data between programs or transactions:
- Data passing between programs
- Data passing between transactions
Data passing between programs -
CICS provides the below options to pass the data between the CICS application programs –
- COMMAREA
- Queues
- Channels
COMMAREA -
The COMMAREA stands for "communication area." In the context of the LINK and XCTL commands, the COMMAREA option specifies the name of the data area used to pass data from the currently running program to the program being called. Additionally, the COMMAREA option in a RETURN command indicates the name of the data area where data is sent to the transaction identified by the TRANSID option.
Key features -
- Fixed-size storage (Maximum: 32 KB).
- Passed via LINK, XCTL and RETURN commands.
How to use the COMMAREA -
Define COMMAREA in the Calling Program:
...
WORKING-STORAGE SECTION.
01 WS-COMMAREA IC X(100). *> Data to be passed
...
PROCEDURE DIVISION.
EXEC CICS LINK
PROGRAM('PROG2')
COMMAREA(WS-COMMAREA)
LENGTH(100)
END-EXEC.
...
Receive COMMAREA in the Called Program
...
LINKAGE SECTION.
01 WS-COMMAREA IC X(100). *> Data to be passed
...
PROCEDURE DIVISION.
...
Use COMMAREA when passing small amounts of data (under 32 KB) between programs within the same transaction. COMMAREA is explained in the chapter COMMAREA
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
These are explained in the chapter Queues
Channels & Containers -
The modern method of transferring data between CICS programs is called a channel. CHANNELS and CONTAINERS are an advanced version of COMMAREA used to pass large amounts of data (greater than 32 KB) between CICS programs. They can be passed between programs instead of COMMAREAs on LINK, XCTL, and RETURN commands.
How to Use CHANNELS & CONTAINERS? -
Define and Pass Data in the Calling Program:
...
PROCEDURE DIVISION.
EXEC CICS PUT CONTAINER('CON1')
FROM(WS-DATA)
CHANNEL('CH1')
END-EXEC.
EXEC CICS LINK
PROGRAM('PROG2')
CHANNEL('CH1')
END-EXEC.
...
Receive Data in the Called Program:
...
PROCEDURE DIVISION.
EXEC CICS GET CONTAINER('CON1')
INTO(WS-DATA)
CHANNEL('CH1')
END-EXEC.
...
Use CHANNELS when passing large amounts of data (>32 KB) between programs.
Data passing between Transactions -
Below are the two options to pass the data between the transactions –
- Main storage areas
- CICS recoverable resources
Main storage areas -
Main storage areas are temporary storage areas that is used to transfer the data from one transaction to another transaction. These areas can't be recovered. The benefits of main storage areas are useful when recovery is not a priority or when data is transferred between programs handling the same task. Main storage areas can be used to share data among transactions, including -
- The communication area (COMMAREA)
- The common work area (CWA)
- Temporary storage (main)
- The terminal control table user area (TCTUA)
CICS recoverable resources -
Recoverable resources are used to transfer the data from one transaction to another transaction. These are recoverable. The recoverable resources used for communication between transactions include -
- Temporary storage (auxiliary)
- Transient data queues
- User files
- DL/I and DB2 databases (user-maintained)
- Coupling facility data tables