Chapter 15 Exercises: CICS Channels and Containers


Section 15.1 — The COMMAREA Problem

Exercise 15.1

A CICS application uses a COMMAREA with the following copybook to pass customer account data:

01  DFHCOMMAREA.
    05  CA-CUST-ID          PIC X(10).
    05  CA-CUST-NAME        PIC X(40).
    05  CA-ACCT-TABLE.
        10  CA-ACCT-COUNT   PIC S9(4) COMP.
        10  CA-ACCT-ENTRY OCCURS 50 TIMES.
            15  CA-ACCT-NO  PIC X(12).
            15  CA-ACCT-TYP PIC X(2).
            15  CA-ACCT-BAL PIC S9(11)V99 COMP-3.
    05  CA-RESPONSE-CODE    PIC X(4).

Calculate the total COMMAREA size. The business now requires support for up to 200 accounts per customer. Calculate the new required size and determine whether COMMAREA can support it.

Exercise 15.2

List three workarounds that shops commonly use when COMMAREA data exceeds 32,760 bytes. For each workaround, identify one specific failure mode that can occur in production.

Exercise 15.3

Kwame's team at CNB has a funds transfer program that currently uses a 24KB COMMAREA. They need to add a variable-length list of compliance records (each 180 bytes, up to 300 records). Calculate whether this fits in a COMMAREA and, if not, explain why the TS queue overflow approach introduces transactional integrity risks.

Exercise 15.4

Sandra's team at Federal Benefits has identified 14 programs that share a single 28KB COMMAREA copybook. Only 3 of those programs use more than 8KB of the fields. Explain the maintenance cost of this design and how it could lead to a production incident during a routine copybook change.

Exercise 15.5

A programmer proposes solving the 32KB limit by passing a GETMAIN address in the COMMAREA so the called program can access a larger storage area. Explain three reasons why this approach fails for DPL (Distributed Program Link) scenarios.


Section 15.2 — Channels and Containers Architecture

Exercise 15.6

Explain the difference between a CHAR container and a BIT container. Give two examples of data that should be stored in each type.

Exercise 15.7

A channel named CUST-INQUIRY contains the following containers:

CUST-REQUEST     (BIT,  120 bytes)
CUST-RESPONSE    (BIT,  4,800 bytes)
CUST-MESSAGES    (CHAR, 2,000 bytes)
CUST-ERROR       (BIT,  320 bytes)

The channel is passed via DPL from CICSAOR1 (CCSID 037, US EBCDIC) to CICSAOR2 (CCSID 500, International EBCDIC). Which containers will undergo code page conversion? What happens to the BIT containers during transmission?

Exercise 15.8

Describe the lifecycle of a channel from creation to destruction. At what point is a channel implicitly created? When is it destroyed? Is there an explicit DELETE CHANNEL command?

Exercise 15.9

A program receives a channel via LINK and issues another LINK to a second program without specifying a CHANNEL option. What happens to the channel? Explain the concept of "current channel" propagation.

Exercise 15.10

Ahmad at Pinnacle Health is designing a patient data exchange channel. The data includes a patient demographics structure (COMP-3 fields for insurance codes), a physician notes field (free-text EBCDIC), and a medical image thumbnail (binary JPEG). Specify the correct CHAR/BIT designation for each container and justify your choices.


Section 15.3 — Implementing Channels in COBOL

Exercise 15.11

Write the COBOL code to: 1. Create a channel named PAYMENT-CHAN 2. PUT a container named PAY-REQUEST containing a 500-byte payment request structure (BIT) 3. PUT a container named PAY-NOTES containing a variable-length text field (CHAR) 4. LINK to program PAYPRC00 with the channel 5. GET the PAY-RESPONSE container from the channel after the LINK returns

Include proper RESP/RESP2 checking for all EXEC CICS commands.

Exercise 15.12

A GET CONTAINER operation returns DFHRESP(LENGERR). The INTO area is 2,000 bytes, and FLENGTH is set to 3,500 after the GET. Explain what happened and write the COBOL code to handle this situation by using GET with SET to retrieve the full data.

Exercise 15.13

Write a COBOL paragraph that browses all containers in a channel named AUDIT-CHAN, displaying each container's name. Handle the STARTBROWSE, GETNEXT loop, and ENDBROWSE commands with proper response code checking.

Exercise 15.14

Write a MOVE CONTAINER command that transfers the container RAW-DATA from channel INPUT-CHAN to channel OUTPUT-CHAN, renaming it to PROCESSED-DATA during the move. Explain why this is more efficient than a GET followed by a PUT for large containers.

Exercise 15.15

A programmer writes the following code and reports that the container is not found by the receiving program:

      * Sending program
           MOVE 'Customer-Data' TO WS-CONT-NAME
           EXEC CICS PUT CONTAINER(WS-CONT-NAME)
                CHANNEL('CUST-CHAN')
                FROM(WS-CUST-REC)
                FLENGTH(LENGTH OF WS-CUST-REC)
                BIT
           END-EXEC

      * Receiving program
           EXEC CICS GET CONTAINER('CUSTOMER-DATA')
                CHANNEL('CUST-CHAN')
                INTO(WS-CUST-REC)
                FLENGTH(WS-DATA-LEN)
                RESP(WS-RESP)
           END-EXEC

Identify the bug and explain the fix.

Exercise 15.16

Write COBOL code to PUT a CHAR container with data in CCSID 1208 (UTF-8) and then GET it with conversion to CCSID 037 (US EBCDIC). Show both the PUT and GET commands with the appropriate CCSID options.


Section 15.4 — Channel Patterns

Exercise 15.17

Design a multi-container channel for Pinnacle Health's patient admission transaction. The transaction involves: - Patient demographics (800 bytes, contains packed decimal fields) - Insurance information (1,200 bytes, contains packed decimal fields) - Physician notes (variable length, up to 10,000 bytes, text) - Lab orders (variable count, each 150 bytes, contains packed decimal) - Admission metadata (200 bytes, text)

Specify each container's name, type (CHAR/BIT), and approximate size. Justify your CHAR/BIT choices.

Exercise 15.18

Define a standard error container structure for the HA Banking system. The structure must include: error severity, error code, source program, error message text, EIBRESP/EIBRESP2 values, a timestamp, and an abend code. Write the COBOL 01-level definition and explain why you chose BIT or CHAR for this container.

Exercise 15.19

Describe the pipeline pattern for a channel that flows through four programs: validation, enrichment, processing, and formatting. For each program, list which containers it reads and which it creates. Explain why programs should not modify containers created by other programs in the pipeline.

Exercise 15.20

Rob at CNB suggests creating a channel with 40 containers, each holding a single field from their customer record. Kwame argues for 6 containers grouped by logical function. Evaluate both approaches with respect to: (a) storage overhead, (b) code complexity, (c) cross-region DPL performance, and (d) maintainability. Which approach would you recommend and why?

Exercise 15.21

Design a metadata container for the HA Banking system that includes version control, correlation tracking, and hop counting. Write the COBOL 01-level definition and explain how each field is used during a multi-program transaction flow.


Section 15.5 — Channels with Web Services and DPL

Exercise 15.22

A CICS web service pipeline receives a SOAP request and places the data into the DFHWS-DATA container. Write the COBOL code for a service handler program that: 1. GETs the request data from DFHWS-DATA 2. Performs a simple validation (check that an account number field is not spaces) 3. PUTs the response data back into DFHWS-DATA 4. PUTs an error response into DFHWS-DATA if validation fails

Exercise 15.23

Carlos at SecureFirst needs to LINK to a fraud detection program (FRAUD010) in region SECUAOR2 via DPL, passing a channel with customer transaction data. The channel includes: - A BIT container with account structures (COMP-3 fields) - A CHAR container with customer name and address (EBCDIC text)

Write the LINK command and explain what CICS does with each container type during the DPL transmission if SECUAOR2 uses a different CCSID than the calling region.

Exercise 15.24

Explain why channels are required (not merely recommended) for CICS web services integration. What role do the DFHWS-* containers play in the web service pipeline? Can a web service handler program use COMMAREA instead?


Section 15.6 — Migration from COMMAREA to Channels

Exercise 15.25

Write a wrapper program that accepts a channel named ACCT-CHAN, extracts data from containers ACCT-REQUEST and ACCT-OPTIONS into a COMMAREA layout, calls the legacy program ACCTINQ0 with COMMAREA, and puts the response back into a container named ACCT-RESPONSE. Include error handling for missing containers.

Exercise 15.26

Write a dual-interface program skeleton that detects whether it was invoked with a channel or a COMMAREA. The program should: 1. Check for a current channel using EXEC CICS ASSIGN CHANNEL 2. If channel is present, perform PROCESS-VIA-CHANNEL 3. If no channel, check for COMMAREA via EIBCALEN 4. If COMMAREA is present, perform PROCESS-VIA-COMMAREA 5. If neither, abend with code 'NODA'

Exercise 15.27

Lisa at CNB is planning a COMMAREA-to-channels migration for 23 programs. Five of those programs are called by external partners via DPL. Eight are internal-only. Ten are called by both internal and external callers. Draft a three-phase migration sequence that minimizes risk and avoids a big-bang cutover. Specify which programs to migrate in each phase and why.

Exercise 15.28

A legacy COMMAREA uses REDEFINES to support three different record types:

01  DFHCOMMAREA.
    05  CA-RECORD-TYPE    PIC X(2).
    05  CA-INQUIRY-DATA REDEFINES CA-RECORD-TYPE.
        10  FILLER        PIC X(2).
        10  CA-INQ-ACCT   PIC X(12).
        10  CA-INQ-OPTS   PIC X(4).
    05  CA-UPDATE-DATA  REDEFINES CA-RECORD-TYPE.
        10  FILLER        PIC X(2).
        10  CA-UPD-ACCT   PIC X(12).
        10  CA-UPD-FIELDS PIC X(500).
    05  CA-DELETE-DATA  REDEFINES CA-RECORD-TYPE.
        10  FILLER        PIC X(2).
        10  CA-DEL-ACCT   PIC X(12).
        10  CA-DEL-REASON PIC X(80).

Redesign this as a channel-based interface with separate containers for each operation type. Explain how the called program determines which operation to perform.


Section 15.7 — Performance Considerations

Exercise 15.29

A transaction creates a channel with the following containers and sends it via DPL to a remote region:

Container Type Size
META-DATA BIT 200 bytes
CUST-DATA BIT 4,000 bytes
TXN-HIST BIT 85,000 bytes
CUST-NOTES CHAR 15,000 bytes
AUDIT-LOG BIT 2,500 bytes

Calculate the total data volume transmitted. Which container is the primary candidate for optimization if DPL latency is unacceptable? Suggest two strategies to reduce the data volume.

Exercise 15.30

Compare the storage overhead of passing 50KB of data using: (a) a single container, (b) 5 containers of 10KB each, (c) 50 containers of 1KB each. Estimate the control block overhead for each approach and determine at what point over-decomposition becomes a problem.

Exercise 15.31

Marcus at Federal Benefits reports that a transaction using GET CONTAINER with INTO is consuming excessive CPU. The container holds 8MB of XML data, and the program only needs the first 200 bytes (a header element). Explain why this is inefficient and write the code to use GET with SET instead, accessing only the header portion.

Exercise 15.32

Yuki at SecureFirst is deciding between channels and TS queues for a security audit trail that must be accessible by multiple transactions over a 30-minute window. The data volume is approximately 500KB per audit trail. Explain why channels are not appropriate for this use case and recommend the correct approach.

Exercise 15.33

Design a performance test plan for comparing COMMAREA-based DPL versus channel-based DPL for the HA Banking system's funds transfer transaction. Specify: (a) what metrics to measure, (b) what data volumes to test, (c) how to isolate channel overhead from network overhead, and (d) what the acceptance criteria should be.


Integration and Design Exercises

Exercise 15.34

Diane at Pinnacle Health needs to pass patient allergy information (variable count, up to 200 allergies at 50 bytes each) between a patient intake program and a medication verification program. The medication verification program runs in a remote CICS region. Design the complete channel interface, including error handling, metadata, and CHAR/BIT designations. Write the PUT code for the sending program and the GET code for the receiving program.

Exercise 15.35

The HA Banking system needs a channel design that supports the following flow:

TRAN0000 (TOR) -> TRAN0010 (AOR1) -> TRAN0020 (AOR2) -> TRAN0010 (AOR1) -> TRAN0000 (TOR)

The channel crosses region boundaries twice. Draw the channel flow diagram, specifying which containers exist at each step, which containers cross region boundaries, and where CHAR container conversion occurs. Identify any potential performance issues with this topology.

Exercise 15.36

Write a COBOL utility program that receives a channel, browses all containers, logs each container's name and data length to a CICS journal, and returns. This program should be usable as a debugging aid that can be inserted into any channel-based LINK chain without modifying the channel contents.

Exercise 15.37

CNB's Kwame is reviewing a junior programmer's channel design that uses container names like C1, C2, C3, C4, and C5. The programmer argues that short names save storage. Draft Kwame's code review feedback explaining why descriptive container names are worth the negligible storage cost, and propose a naming convention for CNB's channel-based applications.