Chapter 15 Key Takeaways: CICS Channels and Containers
The COMMAREA Ceiling Is Real
- COMMAREA has a hard 32,760-byte maximum that will never increase. Web services, complex data structures, and SOA have made this limit a genuine constraint, not a theoretical one.
- The fixed-structure coupling of COMMAREA copybooks means every program includes every field. Adding one field requires recompiling every program that shares the copybook.
- TS queue overflow, TWA/CWA sharing, and GETMAIN address passing are workarounds that force application code to solve infrastructure problems. Channels move the solution into the infrastructure.
Channels and Containers — Core Concepts
- A channel is a named collection of containers. A container is a named block of data with no practical size limit.
- Containers are accessed by name, not by position. Programs that don't need a container can ignore it entirely.
- CHAR containers hold character data and are eligible for automatic CCSID conversion during DPL. BIT containers hold binary data and are transmitted without conversion.
- Always specify CHAR or BIT explicitly. Never rely on the default.
- Never put packed decimal, COMP, or COMP-3 fields into a CHAR container if there is any chance the container will cross a region boundary.
API Essentials
- PUT CONTAINER creates or replaces a container. Always specify FLENGTH.
- GET CONTAINER retrieves data. Use INTO for fixed-length structures; use SET for variable-length data to avoid unnecessary copies.
- MOVE CONTAINER transfers a container between channels without copying through working storage. Use AS to rename during the move.
- DELETE CONTAINER removes a container from a channel.
- STARTBROWSE/GETNEXT/ENDBROWSE enumerate containers in a channel when you don't know what's present.
- Container names are case-sensitive. Establish a naming convention and enforce it.
Design Patterns That Work
- Multi-container pattern: Decompose data into logical containers. Programs read only what they need.
- Error container pattern: A standard error structure in a known container name, checked by every program on entry. Enables error propagation without coupling.
- Metadata container pattern: Version, correlation ID, hop count, trace flag. Provides traceability across multi-program flows.
- Request/response pattern: Clear separation between input and output containers. Neither side modifies the other's containers.
- Pipeline pattern: Each program adds its output as a new container. The channel accumulates results as it flows through the chain.
DPL and Web Services
- Channels are transmitted across MRO and ISC links during DPL. CHAR containers get automatic CCSID conversion; BIT containers are passed byte-for-byte.
- For DPL performance, build purpose-specific channels for remote calls rather than sending the entire channel. Use MOVE CONTAINER to bring results back to the main channel.
- CICS web services are built on channels. The DFHWS-DATA container carries the business data between the pipeline and your handler program.
- If you're writing a web service back-end, channels are required, not optional.
Migration Strategy
- Don't rewrite everything at once. Use the three-phase approach: wrapper programs, dual-interface programs, then full migration.
- Wrapper programs let new channel-based callers use existing COMMAREA programs without modification.
- Dual-interface programs detect their invocation method (EXEC CICS ASSIGN CHANNEL) and handle both paths.
- Migrate in dependency order: start with simple, isolated programs; finish with complex, cross-cutting ones.
Performance Rules of Thumb
- Under 100KB total channel size: negligible overhead versus COMMAREA for DPL.
- Over 1MB: consider whether all containers need to cross the link.
- Over 10MB: rethink the architecture. This is probably a batch job or an MQ use case.
- GET with SET avoids data copies for large containers.
- Each container has approximately 200-300 bytes of control block overhead. Don't create hundreds of containers per channel.
- Channels are automatically cleaned up when the task ends. No explicit cleanup required (unlike TS queues).
When to Use What
| Scenario | Recommended Approach |
|---|---|
| Fixed structure, < 32KB, local, no web services | COMMAREA |
| Data > 32KB | Channels |
| Variable-length data | Channels |
| Web service back-end | Channels (required) |
| Cross-region DPL with CCSID differences | Channels (CHAR containers) |
| Data shared across transactions | TS queues |
| Data that must survive abends | Recoverable TS queues |
| New development with complex data contracts | Channels from the start |