CICS

CICS Channels and Containers: Keep Request State Intact Across LINK Boundaries

A CICS transaction can appear to lose an input value even though the screen program placed it in a container successfully. This tutorial shows how to trace state through a `LINK` using channels and containers, and how to distinguish an application contract problem from an incorrect assumption about task state.

Terminal inputCICS taskValidationSafe response
Original DBala learning flow — a visual summary of this article’s practical decision path.

A CICS transaction can appear to lose an input value even though the screen program placed it in a container successfully. This tutorial shows how to trace state through a LINK using channels and containers, and how to distinguish an application contract problem from an incorrect assumption about task state.

The names, values, and program names below are fictional. CICS releases, language interfaces, naming rules, and local error-handling standards vary. Do not change a live transaction, purge a task, or retry an update merely because a downstream program reports an empty container.

The boundary that matters

A channel is a named collection of containers. A container holds one named piece of data, such as a request key, a validated amount, or a response structure. Unlike a COMMAREA, a channel can carry several separately named data items and is not constrained by the traditional COMMAREA interface pattern.

The practical point is not just capacity. Containers make the handoff contract visible:

Screen program
  -> channel ORDERCHN
     -> container REQUEST-KEY
     -> container ORDER-INPUT
  -> LINK to validation program
     -> container VALIDATED-ORDER
  -> LINK to update program

Every program in this flow must agree on three things: which channel it uses, which container name it expects, and the layout and length of the bytes inside that container. A successful LINK does not prove that agreement. It only proves that control reached and returned from the linked program.

A small worked example

Assume ORDR001 validates an order number entered on a BMS screen. It places the order number in container REQUEST-KEY on channel ORDERCHN, then links to ORDR020. The receiving program reads that container and writes a separate VALID-STATUS container for the caller.

Here is a compact COBOL-style illustration. Application copybooks and site wrappers may use different field definitions.

       MOVE 'ORDERCHN'    TO WS-CHANNEL-NAME
       MOVE 'REQUEST-KEY' TO WS-CONTAINER-NAME
       MOVE MAP-ORDER-NO  TO WS-REQUEST-KEY

EXEC CICS
PUT CONTAINER(WS-CONTAINER-NAME)
CHANNEL(WS-CHANNEL-NAME)
FROM(WS-REQUEST-KEY)
FLENGTH(LENGTH OF WS-REQUEST-KEY)
RESP(WS-RESP)
RESP2(WS-RESP2)
END-EXEC

IF WS-RESP NOT = DFHRESP(NORMAL)
PERFORM REPORT-CICS-FAILURE
END-IF

EXEC CICS
LINK PROGRAM('ORDR020')
CHANNEL(WS-CHANNEL-NAME)
RESP(WS-RESP)
RESP2(WS-RESP2)
END-EXEC.
```

In ORDR020, the equivalent retrieval must identify the same channel and the same container name:

       MOVE 'ORDERCHN'    TO WS-CHANNEL-NAME
       MOVE 'REQUEST-KEY' TO WS-CONTAINER-NAME

EXEC CICS
GET CONTAINER(WS-CONTAINER-NAME)
CHANNEL(WS-CHANNEL-NAME)
INTO(WS-REQUEST-KEY)
FLENGTH(LENGTH OF WS-REQUEST-KEY)
RESP(WS-RESP)
RESP2(WS-RESP2)
END-EXEC.
```

If the retrieved order number is blank, avoid concluding that PUT CONTAINER failed. The receiving program may have asked for REQUESTKEY rather than REQUEST-KEY; it may have used a differently named channel; or its target area may not match the sending layout. A blank business field can also be valid input, so presence and value are separate checks.

Diagnose the handoff, not just the symptom

Start with one transaction instance and a safe non-production reproduction where possible. Record the transaction identifier, task number or correlation value permitted by local policy, timestamp, program sequence, CICS RESP and RESP2, channel name, container name, and requested versus returned length. Do not put order data or other sensitive payloads into a broadly visible trace.

Then work through this decision path:

Did PUT return NORMAL?
  No  -> investigate the CICS response before following the LINK.
  Yes -> did LINK name and pass the intended channel?
           No  -> correct the caller's interface contract.
           Yes -> did GET return NORMAL and a plausible length?
                    No  -> compare channel/container spelling and lifecycle.
                    Yes -> compare the copybook layout and downstream logic.

A useful diagnostic is to log metadata at each boundary, not the full container content: channel=ORDERCHN, container=REQUEST-KEY, length=12, and the CICS response pair. If local tooling supports it, a controlled trace in a test region can confirm the commands and program sequence. Trace output is evidence, not a substitute for reviewing the source and deployed load modules.

The length check catches a quieter class of defect

Container names can match while layouts do not. For example, a sender may have moved from an 8-byte order number to a 12-byte alphanumeric key, while a receiver still defines an 8-byte field. The receiver can either reject the request based on returned length or accept truncated data depending on its coding and interface. Neither outcome should be treated casually.

Define the payload in a shared copybook or an explicitly versioned interface contract. On receipt, validate the returned length before using a field for a read or update. If a layout needs to evolve, a safer design is often a new container name such as ORDER-INPUT-V2, with a planned period in which callers and receivers are deployed together. This is a design choice; local release policies may instead require a coordinated single deployment.

Do not reuse a generic container such as WORKAREA for unrelated programs. It hides ownership and makes later maintenance harder. Names that describe the business purpose make traces and support notes more useful.

Common failure cases

A linked program creates a new channel name. The program may successfully put its output on ORDER-RESULT while the caller later looks on ORDERCHN. This is an interface mismatch, not necessarily a CICS failure.

A program assumes containers persist into a later task. A channel passed through a LINK belongs to that execution flow. If the transaction returns to the terminal and a later user action starts another task, reconstruct required state through the application’s approved design—for example, validated screen input or a controlled temporary-storage pattern. Do not assume an earlier channel is available.

A response is ignored. GET CONTAINER can return a non-normal response when a container is absent or another condition occurs. Continuing with an uninitialized target area can turn an interface defect into a wrong-account lookup or a misleading validation message.

The update program trusts a container blindly. Data passed internally is still input. Before an update, validate key format, authorization context, state transition, and any version or timestamp used to prevent a stale update.

Support checklist before changing or retrying

For command-specific meanings, consult the IBM documentation for the CICS PUT CONTAINER, GET CONTAINER, and LINK commands for the installed CICS version. The exact response values and operational tooling can differ by environment.

Practical takeaway

Treat each channel/container exchange as a small, named interface contract: same channel, same container, known layout, checked response, and checked length. That evidence narrows an apparently “lost state” incident without turning an uncertain retry or source change into a second problem.

← Back to all articles