Chapter 24: CICS Transaction Processing Fundamentals -- Key Takeaways

Chapter Summary

CICS (Customer Information Control System) is the transaction processing middleware that has served as the backbone of online mainframe applications for over five decades, and learning to write COBOL programs that run under CICS is an essential enterprise development skill. This chapter introduced the fundamental architecture of CICS, the EXEC CICS command interface for COBOL, the pseudo-conversational programming model that maximizes system throughput, and the BMS (Basic Mapping Support) facility for building terminal screens.

CICS provides a managed execution environment for COBOL programs, handling terminal communication, task scheduling, storage management, program loading, and recovery services. COBOL programs running under CICS do not use standard COBOL file I/O, ACCEPT, or DISPLAY statements for user interaction; instead, they issue EXEC CICS commands delimited by END-EXEC to request services from the CICS runtime. This command-level interface replaced the older macro-level interface and provides a clean separation between application logic and system services.

The pseudo-conversational programming model is the defining architectural pattern of CICS application design. Instead of holding a task active while waiting for user input (conversational mode, which wastes system resources), a pseudo-conversational program sends a screen to the user, terminates its task, and relies on CICS to start a new task when the user responds. The COMMAREA (Communication Area) preserves state between pseudo-conversational interactions. We covered BMS map definitions that describe screen layouts, the SEND MAP and RECEIVE MAP commands that transmit and receive screen data, and the DFHCOMMAREA that provides access to the communication area in the LINKAGE SECTION. The chapter also introduced error handling through both the legacy HANDLE CONDITION mechanism and the modern RESP option on EXEC CICS commands.

Key Concepts

  • CICS is a transaction processing middleware that provides managed execution of COBOL programs with services for terminal I/O, storage management, program control, file access, and recovery.
  • Every CICS command in a COBOL program is delimited by EXEC CICS and END-EXEC; the CICS translator processes these commands during a pre-compilation step similar to the DB2 precompiler.
  • The pseudo-conversational model sends a screen to the user and terminates the task; when the user presses a key, CICS starts a new task that receives the user's input, preserving state through COMMAREA.
  • COMMAREA (Communication Area) is a block of data passed between pseudo-conversational task invocations via the RETURN TRANSID command, preserving application state across user interactions.
  • DFHCOMMAREA is the name of the LINKAGE SECTION item that maps the incoming COMMAREA; the program accesses it through the PROCEDURE DIVISION USING DFHCOMMAREA clause.
  • BMS (Basic Mapping Support) separates screen layout definition (the physical map) from application data (the symbolic map), enabling screen changes without modifying COBOL code.
  • SEND MAP transmits a formatted screen to the terminal using a BMS map; RECEIVE MAP reads user input from the terminal into the symbolic map's data fields.
  • A BMS mapset is defined using assembler macros (DFHMSD, DFHMDI, DFHMDF) and is assembled into a physical map (load module) and a symbolic map (COBOL copybook).
  • The EIBAID field in the Execute Interface Block (EIB) contains the attention key pressed by the user (ENTER, PF1 through PF24, CLEAR, PA keys), enabling the program to determine what action the user requested.
  • HANDLE CONDITION is the legacy error-handling mechanism that directs control to a specified label when a particular CICS condition (such as NOTFND, DUPREC, or MAPFAIL) occurs.
  • The RESP option on EXEC CICS commands is the modern alternative to HANDLE CONDITION, returning the condition code in a COBOL data item that the program tests with an EVALUATE or IF statement.
  • EIBRESP and EIBRESP2 in the EIB provide response information after each EXEC CICS command, with EIBRESP containing the primary response code and EIBRESP2 providing additional detail.
  • The CICS translator step processes the COBOL source to convert EXEC CICS commands into COBOL CALL statements, similar to the DB2 precompiler step for SQL.
  • Standard COBOL file I/O (OPEN, READ, WRITE, CLOSE), ACCEPT, DISPLAY, and STOP RUN are not permitted in CICS COBOL programs; all I/O and program termination must use EXEC CICS commands.

Common Pitfalls

  • Using conversational programming instead of pseudo-conversational: Holding a task active while waiting for user input wastes CICS resources and limits the number of concurrent users the system can support. Always use the pseudo-conversational model.
  • Forgetting to RETURN TRANSID with COMMAREA: If a pseudo-conversational program executes EXEC CICS RETURN without specifying TRANSID and COMMAREA, the user's next keystroke will not restart the transaction and all state will be lost.
  • COMMAREA length mismatches: The length of the COMMAREA passed on RETURN TRANSID must match the length expected by the receiving program. A mismatch can cause truncation or storage overlay errors.
  • Not checking EIBAID before RECEIVE MAP: If the user presses CLEAR or a PA key, there is no map data to receive. Attempting RECEIVE MAP without first checking EIBAID for these keys causes a MAPFAIL condition.
  • Using HANDLE CONDITION in new programs: While still supported, HANDLE CONDITION creates implicit branching that is difficult to follow and debug. Use the RESP option on each EXEC CICS command and test the response inline.
  • Issuing STOP RUN in a CICS program: STOP RUN is not valid in CICS and will cause an abend. Use EXEC CICS RETURN END-EXEC to terminate the program or transaction.
  • Ignoring BMS symbolic map attribute bytes: The symbolic map includes attribute byte fields for each screen field. Failing to set attributes (such as UNPROT for input fields or BRT for highlighted fields) produces screens that do not behave as expected.
  • Not initializing the symbolic map before SEND MAP: Sending a map without initializing the symbolic map's data fields results in residual data from previous transactions appearing on screen. Use MAPONLY on the first SEND or initialize all fields.

Quick Reference

      * CICS program structure
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CUSTINQ.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-RESP              PIC S9(8) COMP.
       01  WS-COMMAREA.
           05  WS-CA-STATE      PIC X(01).
               88  FIRST-TIME   VALUE SPACES.
           05  WS-CA-CUST-ID    PIC X(10).
       COPY CUSTMAP.
       LINKAGE SECTION.
       01  DFHCOMMAREA          PIC X(11).

       PROCEDURE DIVISION.
       0000-MAIN.
           IF EIBCALEN = 0
               PERFORM 1000-FIRST-TIME
           ELSE
               MOVE DFHCOMMAREA TO WS-COMMAREA
               PERFORM 2000-PROCESS-INPUT
           END-IF
           EXEC CICS RETURN
               TRANSID('CINQ')
               COMMAREA(WS-COMMAREA)
               LENGTH(LENGTH OF WS-COMMAREA)
           END-EXEC.

      * Send a BMS map
       1000-FIRST-TIME.
           MOVE LOW-VALUES TO CUSTMAPO
           EXEC CICS SEND
               MAP('CUSTMAP')
               MAPSET('CUSTSET')
               ERASE
           END-EXEC.

      * Receive map and check response
       2000-PROCESS-INPUT.
           EVALUATE EIBAID
               WHEN DFHENTER
                   PERFORM 2100-HANDLE-ENTER
               WHEN DFHPF3
                   EXEC CICS RETURN END-EXEC
               WHEN OTHER
                   PERFORM 2900-INVALID-KEY
           END-EVALUATE.

       2100-HANDLE-ENTER.
           EXEC CICS RECEIVE
               MAP('CUSTMAP')
               MAPSET('CUSTSET')
               INTO(CUSTMAPI)
               RESP(WS-RESP)
           END-EXEC
           IF WS-RESP = DFHRESP(NORMAL)
               PERFORM 3000-LOOKUP-CUSTOMER
           END-IF.

What's Next

Chapter 25 explores advanced CICS programming techniques including file control commands for VSAM access under CICS, temporary storage and transient data queues for inter-task communication, program control commands (LINK, XCTL, RETURN) for building multi-program transactions, interval control for deferred and scheduled processing, channel and container programming as the modern replacement for COMMAREA, CICS web services integration, and CICS security. These advanced features enable you to build complete, production-quality CICS applications.