CICS
CICS (Customer Information Control System, current: CICS Transaction Server for z/OS 6.x) runs online transactions: thousands of short programs executing concurrently for terminal users, web services, and APIs.
37.1 Concepts
CICS (Customer Information Control System, current: CICS Transaction Server for z/OS 6.x) runs online transactions: thousands of short programs executing concurrently for terminal users, web services, and APIs.
4-character ID (e.g., CINQ) mapped to a starting program One running instance of a transaction
Exec Interface Block: EIBCALEN (COMMAREA length), EIBAID (key pressed), EIBTRNID, EIBRESP
Up to 32 KB of data passed between programs or saved between pseudo-conversational steps Channels & containers
Modern replacement for COMMAREA: named containers of any size grouped in a channel
Basic Mapping Support: defines 3270 screens (maps) with assembler macros; generates a physical map and a COBOL symbolic-map copybook Translator / coprocessor
Converts EXEC CICS into calls (CICS compiler option for the integrated translator)
37.2 Pseudo-conversational design
A conversational program waits for the user while holding resources — it doesn't scale. A pseudo-conversational program sends a screen, then ends with RETURN TRANSID(...) COMMAREA(...); when the user presses a key, CICS starts a new task of the same transaction, passing the saved COMMAREA. The program checks EIBCALEN to know whether it is the first invocation.
User types CINQ ──► task 1: EIBCALEN = 0 → send empty map → RETURN TRANSID('CINQ') COMMAREA
User enters ID ──► task 2: EIBCALEN > 0 → RECEIVE MAP → READ FILE → SEND MAP → RETURN TRANSID
User presses F3 ──► task 3: send goodbye text → RETURN (no TRANSID) → conversation ends37.3 BMS map
The generated symbolic map (COPY CUSTSET) contains CUSTMAPI (input) and CUSTMAPO (output) structures with, for each named field, suffixes L (length), F (flag), A (attribute), I (input), and O (output) — e.g., CUSTIDI, CUSTIDL, NAMEO, MSGO.
CUSTSET DFHMSD TYPE=&SYSPARM,MODE=INOUT,LANG=COBOL,TIOAPFX=YES
CUSTMAP DFHMDI SIZE=(24,80),CTRL=(FREEKB,FRSET)
DFHMDF POS=(1,30),LENGTH=12,ATTRB=ASKIP,INITIAL='CUST INQUIRY'
DFHMDF POS=(3,1),LENGTH=12,ATTRB=ASKIP,INITIAL='CUSTOMER ID:'
CUSTID DFHMDF POS=(3,14),LENGTH=6,ATTRB=(UNPROT,NUM,IC)
DFHMDF POS=(3,21),LENGTH=1,ATTRB=ASKIP
DFHMDF POS=(5,1),LENGTH=5,ATTRB=ASKIP,INITIAL='NAME:'
NAME DFHMDF POS=(5,14),LENGTH=30,ATTRB=(ASKIP,BRT)
DFHMDF POS=(7,1),LENGTH=8,ATTRB=ASKIP,INITIAL='BALANCE:'
BAL DFHMDF POS=(7,14),LENGTH=15,ATTRB=(ASKIP,BRT)
MSG DFHMDF POS=(23,1),LENGTH=79,ATTRB=(ASKIP,BRT)
DFHMSD TYPE=FINAL
END37.4 Inquiry program
Notes: CICS programs must not use STOP RUN, ACCEPT, DISPLAY (to a terminal), or COBOL file I/O — CICS commands do all I/O. RESP options with DFHRESP(...) replace the old HANDLE CONDITION style.
IDENTIFICATION DIVISION.
PROGRAM-ID. CUSTINQ.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RESP PIC S9(8) COMP.
01 WS-COMMAREA.
05 WS-LAST-CUST-ID PIC X(6).
01 WS-BYE-MSG PIC X(20) VALUE "SESSION ENDED".
01 ED-BAL PIC -ZZZ,ZZZ,ZZ9.99.
COPY CUSTSET.
COPY CUSTREC.
COPY DFHAID.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(6).
PROCEDURE DIVISION.
0000-MAIN.
IF EIBCALEN = 0
MOVE LOW-VALUES TO CUSTMAPO
MOVE "ENTER A CUSTOMER ID, F3 TO EXIT" TO MSGO
PERFORM 8000-SEND-MAP-ERASE
ELSE
MOVE DFHCOMMAREA TO WS-COMMAREA
EVALUATE EIBAID
WHEN DFHPF3
EXEC CICS SEND TEXT FROM(WS-BYE-MSG)
LENGTH(LENGTH OF WS-BYE-MSG)
ERASE FREEKB
END-EXEC
EXEC CICS RETURN END-EXEC
WHEN OTHER
PERFORM 2000-PROCESS-INPUT
END-EVALUATE
END-IF
…37.5 More CICS commands
LINK PROGRAM(...) COMMAREA(...) / CHANNEL(...) Call a program and return XCTL PROGRAM(...) Transfer control (no return)
READ, WRITE, REWRITE, DELETE, STARTBR/READNEXT/ENDBR FILE(...) VSAM file access WRITEQ TS/READQ TS, WRITEQ TD
Temporary storage (scratchpad) and transient data queues PUT CONTAINER/GET CONTAINER... CHANNEL(...) Channels and containers START TRANSID(...) Start a transaction asynchronously SYNCPOINT / SYNCPOINT ROLLBACK
Commit or back out recoverable resources (VSAM, Db2, MQ) Embedded SQL works in CICS programs too (Db2 attachment). CICS also exposes COBOL programs as web services and JSON/REST endpoints (with z/OS Connect — Chapter 40).