Channels are the modern way to pass data between CICS programs and transactions. A channel is a named collection of containers that provides a flexible and efficient mechanism for inter-program communication.
A channel is a logical grouping of containers that can be passed between programs using LINK, XCTL, or START commands. Unlike the traditional COMMAREA, channels can carry multiple named data items (containers) of varying sizes and types.
Each channel has a name that can be up to 16 characters long. Channel names help identify the purpose and content of the data being passed.
A channel can contain multiple containers, each with its own name and data. This allows you to pass complex data structures with multiple related pieces of information.
Channels are associated with a specific task and exist for the duration of that task. They are automatically deleted when the task terminates.
Channels are typically created implicitly when you create the first container on a new channel:
12345EXEC CICS PUT CONTAINER('CUSTOMER-ID') FROM(WS-CUSTOMER-ID) FLENGTH(LENGTH OF WS-CUSTOMER-ID) CHANNEL('ORDER-CHANNEL') END-EXEC.
You can check if a channel exists and retrieve its name:
123456789EXEC CICS GET CHANNEL(WS-CHANNEL-NAME) RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE = DFHRESP(NORMAL) DISPLAY 'Current channel: ' WS-CHANNEL-NAME ELSE DISPLAY 'No current channel' END-IF.
Pass a channel to another program using the CHANNEL option on LINK or XCTL:
1234567891011121314151617* Create containers on channel EXEC CICS PUT CONTAINER('INPUT-DATA') FROM(WS-INPUT-DATA) FLENGTH(LENGTH OF WS-INPUT-DATA) CHANNEL('WORK-CHANNEL') END-EXEC. * Link to program passing the channel EXEC CICS LINK PROGRAM('SUBPROG') CHANNEL('WORK-CHANNEL') END-EXEC. * Retrieve response from container EXEC CICS GET CONTAINER('OUTPUT-DATA') INTO(WS-OUTPUT-DATA) CHANNEL('WORK-CHANNEL') END-EXEC.
When a program is invoked with a channel, that channel becomes the "current channel" for that program. Container commands can omit the CHANNEL parameter when working with the current channel:
12345678910* Working with current channel EXEC CICS GET CONTAINER('INPUT-DATA') INTO(WS-INPUT-DATA) * No CHANNEL parameter needed END-EXEC. EXEC CICS PUT CONTAINER('OUTPUT-DATA') FROM(WS-OUTPUT-DATA) * Still working with current channel END-EXEC.
Create a new channel explicitly if needed (though usually done implicitly through containers):
12EXEC CICS GET CHANNEL('NEW-CHANNEL') END-EXEC.
Delete an entire channel and all its containers:
12EXEC CICS DELETE CHANNEL('TEMP-CHANNEL') END-EXEC.
Start a new transaction and pass a channel to it:
12345678EXEC CICS PUT CONTAINER('REQUEST-DATA') FROM(WS-REQUEST-DATA) CHANNEL('REQUEST-CHANNEL') END-EXEC. EXEC CICS START TRANSID('PROC') CHANNEL('REQUEST-CHANNEL') END-EXEC.
Choose channel names that clearly indicate their purpose and content. Examples: 'ORDER-PROCESSING', 'CUSTOMER-INQUIRY', 'BATCH-CONTROL'.
Plan what containers will be on each channel and document the structure. This helps maintain consistency across programs and makes debugging easier.
Always check if a channel was passed before attempting to access it:
12345678910EXEC CICS GET CHANNEL(WS-CHANNEL-NAME) RESP(WS-RESPONSE) END-EXEC. EVALUATE WS-RESPONSE WHEN DFHRESP(NORMAL) PERFORM PROCESS-WITH-CHANNEL WHEN DFHRESP(CHANNELERR) PERFORM PROCESS-WITHOUT-CHANNEL END-EVALUATE.
Delete channels that are no longer needed, especially in long-running or frequently-executed programs.
Design programs to handle optional containers that may or may not be present on a channel.
| Feature | COMMAREA | Channel |
|---|---|---|
| Maximum size | 32KB | 16MB+ per container |
| Data structures | Single structure | Multiple containers |
| Named items | No | Yes |
| Optional data | Difficult | Easy |
| Extensibility | Limited | High |
Channels can be passed across CICS regions using distributed program link (DPL). The system automatically handles the transfer of all containers on the channel.
Business Transaction Services (BTS) uses channels extensively for passing data between activities. BTS containers can persist beyond task termination.
CICS web services can map between XML/JSON and channel/container structures, making it easy to build modern API interfaces.
Common channel-related response codes:
No current channel exists or the specified channel wasn't found. Check if your program was invoked with a channel.
Invalid request, such as trying to pass both a COMMAREA and a CHANNEL on the same LINK command.
Channel name too long (maximum 16 characters) or other length-related issues.
When migrating existing programs from COMMAREA to channels: