CICS

CICS Pseudo-Conversational Design with COMMAREA: A Production Support Guide

Learn a practical CICS pseudo-conversational design using COMMAREA, EIBCALEN, MAPFAIL, PF-key handling, and production support safeguards.

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

Short introduction

A CICS screen transaction should not normally keep a terminal session active while a person reads a screen or decides what to enter next. Instead, a pseudo-conversational program sends a map, ends, and starts again when the user presses Enter or a PF key. The program carries only the information needed for the next interaction, commonly in a COMMAREA.

This pattern is fundamental to many COBOL/CICS applications, but production incidents often happen at its boundaries: a COMMAREA length is wrong, a stale map field is trusted, a user returns to an old screen after a release, or an error path sends a map without arranging the next transaction. The examples here use generic names and must be adapted to local standards, security rules, and CICS release procedures.

Real-world production use case

Consider a generic service-request inquiry transaction. A user enters a request number, presses Enter, and receives a summary screen. From that screen, the user can choose PF5 to view history or PF12 to leave. The inquiry may read DB2 or VSAM data, but the online program should hold neither a database lock nor an active conversational task while the user is thinking.

A support ticket reports that some users see a blank summary screen after entering a valid number. The batch interface that supplies the data is healthy, and the CICS transaction starts successfully. A safe diagnosis is not to immediately change the data. First establish whether the initial screen is being sent correctly, whether EIBCALEN distinguishes first entry from a return, whether the COMMAREA matches the expected copybook, and whether the program handles MAPFAIL separately from invalid input.

The pseudo-conversational design makes that investigation manageable. Each user action is a short CICS task with a clear start, receive, validation, optional data access, send, and return sequence.

Step-by-step explanation

### 1. Define a small, versioned state area

Use a copybook for the COMMAREA instead of scattered literal offsets. Store only state that is required after the next user action: a screen mode, the selected request number, an error indicator, and optionally a version or release marker. Do not place passwords, full customer records, or large working storage areas in it.

EIBCALEN is the length CICS supplies on entry. A zero length normally means the transaction started without a COMMAREA, such as the first invocation. A positive length means the program should validate that it is at least the size required before referencing fields. Never assume every returning task has the current layout; users can have an old terminal flow active during a deployment.

### 2. Send the first map and return

For a first invocation, initialize the state, clear or protect output fields as appropriate, send the input map, and issue RETURN TRANSID(...) COMMAREA(...) LENGTH(...). RETURN ends the current task. It does not preserve ordinary working-storage values for the next key press, which is why required state must be passed explicitly.

Use a named transaction ID consistently. It is common for the program name and transaction ID to differ, so do not infer one from the other during support analysis.

### 3. Receive and validate the next input

On the next task, receive the map before treating fields as business input. MAPFAIL usually means no modified data was received; it can occur when the user presses Enter without changing an unprotected field. That is different from a bad request number and should have its own message and redisplay logic.

Validate input syntax before accessing DB2 or VSAM. Then validate authorization and business rules. In a real system, follow site conventions for field protection, error messages, audit logging, and security checks.

### 4. Use the attention identifier to route PF keys

The CICS EIBAID field identifies the action that caused the task. For example, a PF12 may return to the menu without querying data, while PF5 may set a history mode and send a different map. Do not rely on a map field alone to decide that a user pressed a PF key.

After each branch, either return to the next transaction with valid state or end cleanly. A common defect is a successful SEND MAP followed by no RETURN; the user sees a screen, but the intended next interaction is not established correctly.

### 5. Keep data access short and recoverable

Read the requested information only after validation. Release or commit resources according to the application design before sending the response screen. Avoid holding a DB2 cursor, enqueue, or update lock while waiting for another terminal input. If an update flow spans multiple screens, use an explicit design for validation, authorization, unit of work, and recovery; a COMMAREA is not a substitute for transaction integrity.

Example COBOL/CICS flow

The following simplified outline shows the control flow. Copybook names, map names, response handling, and error routines are illustrative.

       WORKING-STORAGE SECTION.
       01  WS-RESP                  PIC S9(8) COMP.
       01  WS-MSG                   PIC X(70).
       01  WS-CA-LENGTH             PIC S9(4) COMP VALUE 32.

LINKAGE SECTION.
01 DFHCOMMAREA.
COPY REQINQCA.

PROCEDURE DIVISION.
IF EIBCALEN = 0
PERFORM INITIAL-SCREEN
ELSE
IF EIBCALEN < WS-CA-LENGTH
PERFORM COMMAREA-ERROR
ELSE
PERFORM PROCESS-RETURN
END-IF
END-IF
EXEC CICS RETURN END-EXEC.

INITIAL-SCREEN.
INITIALIZE REQINQ-STATE
MOVE 'ENTER REQUEST NUMBER' TO WS-MSG
PERFORM SEND-INPUT-SCREEN
EXEC CICS RETURN
TRANSID('RINQ')
COMMAREA(DFHCOMMAREA)
LENGTH(WS-CA-LENGTH)
END-EXEC.

PROCESS-RETURN.
EXEC CICS RECEIVE MAP('RINQM') MAPSET('RINQSET')
RESP(WS-RESP)
END-EXEC
IF WS-RESP = DFHRESP(MAPFAIL)
MOVE 'ENTER A REQUEST NUMBER' TO WS-MSG
PERFORM SEND-INPUT-SCREEN
EXEC CICS RETURN TRANSID('RINQ')
COMMAREA(DFHCOMMAREA) LENGTH(WS-CA-LENGTH)
END-EXEC
ELSE
EVALUATE EIBAID
WHEN DFHPF12
CONTINUE
WHEN OTHER
PERFORM VALIDATE-AND-INQUIRE
END-EVALUATE
END-IF.
```

In production code, do not silently ignore RESP and RESP2 values. Use the local error-handling pattern and inspect the CICS message log, transaction dump, and relevant application log when a command fails.

Common mistakes

Practical checklist

Summary

Pseudo-conversational CICS design keeps online work short, scalable, and easier to support. The key discipline is explicit state management: validate the COMMAREA before use, receive and validate input carefully, route PF keys intentionally, and return with the exact state needed for the next task. When a screen flow fails, evidence from EIBCALEN, EIBAID, command responses, logs, and the deployed map/copybook version gives a safer path than guessing or repeatedly restarting the transaction.

← Back to all articles