Chapter 24 Exercises: CICS Transaction Processing Fundamentals
Tier 1: Comprehension (Exercises 1-8)
Exercise 1: CICS Command Classification
Classify each of the following EXEC CICS commands into its functional category: Terminal Control, File Control, Program Control, Interval Control, Task Control, or BMS (Basic Mapping Support). Then state whether each command is typically used in the sending or receiving direction.
* (a)
EXEC CICS SEND MAP('ACCTMAP')
MAPSET('ACCTMS')
FROM(ACCT-MAP-O)
ERASE
END-EXEC
* (b)
EXEC CICS READ FILE('ACCTFIL')
INTO(WS-ACCT-RECORD)
RIDFLD(WS-ACCT-KEY)
END-EXEC
* (c)
EXEC CICS RETURN TRANSID('AINQ')
COMMAREA(WS-COMM-AREA)
LENGTH(WS-COMM-LENGTH)
END-EXEC
* (d)
EXEC CICS XCTL PROGRAM('ACCTUPD')
COMMAREA(WS-COMM-AREA)
END-EXEC
* (e)
EXEC CICS RECEIVE MAP('ACCTMAP')
MAPSET('ACCTMS')
INTO(ACCT-MAP-I)
END-EXEC
* (f)
EXEC CICS START TRANSID('NRPT')
INTERVAL(010000)
END-EXEC
* (g)
EXEC CICS SEND TEXT FROM(WS-ERROR-MSG)
LENGTH(WS-MSG-LEN)
ERASE
END-EXEC
* (h)
EXEC CICS LINK PROGRAM('CALCINT')
COMMAREA(WS-CALC-AREA)
LENGTH(WS-CALC-LEN)
END-EXEC
Exercise 2: Pseudo-Conversational Flow
Trace the execution flow of the following pseudo-conversational program. For each EXEC CICS RETURN, state what happens to the CICS task, what data persists, and what triggers the next execution.
PROCEDURE DIVISION.
0000-MAIN.
EVALUATE TRUE
WHEN EIBCALEN = 0
PERFORM 1000-FIRST-TIME
WHEN CA-STATE = 'MENU'
PERFORM 2000-PROCESS-MENU
WHEN CA-STATE = 'DETAIL'
PERFORM 3000-PROCESS-DETAIL
END-EVALUATE
.
1000-FIRST-TIME.
MOVE 'MENU' TO CA-STATE
EXEC CICS SEND MAP('MENUMAP')
MAPSET('MENUMS')
ERASE
END-EXEC
EXEC CICS RETURN TRANSID('AMNU')
COMMAREA(WS-COMM-AREA)
LENGTH(100)
END-EXEC
.
2000-PROCESS-MENU.
EXEC CICS RECEIVE MAP('MENUMAP')
MAPSET('MENUMS')
INTO(MENU-MAP-I)
END-EXEC
MOVE 'DETAIL' TO CA-STATE
MOVE MENUI-SELECTION TO CA-SELECTED-OPTION
EXEC CICS SEND MAP('DETLMAP')
MAPSET('DETLMS')
ERASE
END-EXEC
EXEC CICS RETURN TRANSID('AMNU')
COMMAREA(WS-COMM-AREA)
LENGTH(100)
END-EXEC
.
- What happens when a user types AMNU at a blank screen and presses Enter?
- What happens when the user enters a menu selection and presses Enter?
- How does the program know which paragraph to execute on each invocation?
- What is stored in the COMMAREA between invocations?
- What happens to the CICS task between the user seeing the screen and pressing Enter?
Exercise 3: EIBRCODE and RESP Analysis
For each EIBRESP value below, state the CICS condition name, what caused it, and the appropriate program response.
- EIBRESP = 13 (after a READ FILE command)
- EIBRESP = 22 (after a WRITE FILE command)
- EIBRESP = 12 (after a READ FILE with UPDATE)
- EIBRESP = 81 (after a RECEIVE MAP command)
- EIBRESP = 27 (after a SEND MAP command)
- EIBRESP = 84 (after a LINK PROGRAM command)
- EIBRESP = 70 (after any command)
Exercise 4: BMS Map Macro Analysis
Given the following BMS map definition, answer the questions below.
ACCTMS DFHMSD TYPE=&SYSPARM, X
MODE=INOUT, X
LANG=COBOL, X
TIOAPFX=YES, X
STORAGE=AUTO
*
ACCTMAP DFHMDI SIZE=(24,80), X
LINE=1, X
COLUMN=1
*
DFHMDF POS=(01,25), X
LENGTH=30, X
ATTRB=(ASKIP,BRT), X
INITIAL='ACCOUNT INQUIRY SYSTEM'
*
ACCTID DFHMDF POS=(05,20), X
LENGTH=10, X
ATTRB=(UNPROT,IC), X
PICIN='X(10)', X
PICOUT='X(10)'
*
ACNME DFHMDF POS=(07,20), X
LENGTH=30, X
ATTRB=(ASKIP,NORM)
*
ACBAL DFHMDF POS=(09,20), X
LENGTH=14, X
ATTRB=(ASKIP,NORM), X
PICOUT='$$$,$$$, MATH1 $,$$$,$$9.99' specification do for ACBAL?
5. If the program needs to change the color of ERRMSG at runtime, which generated field is modified?
### Exercise 5: COMMAREA Design
A pseudo-conversational CICS transaction needs to pass the following information between program invocations:
- Current screen state (menu, inquiry, update, confirm)
- Customer ID being viewed (10 characters)
- Account number (12 characters)
- Last action performed (ADD, UPD, DEL, INQ)
- Error flag and message (1 flag + 60-character message)
- Original record data for update comparison (200 bytes)
- Record modification timestamp (26 characters)
Design a complete COMMAREA copybook. Include 88-level condition names for the screen state and action fields. Explain why the COMMAREA should be kept as small as practical.
### Exercise 6: Conversational vs. Pseudo-Conversational
Explain the difference between conversational and pseudo-conversational programming in CICS. A system supports 500 concurrent terminals. Each user averages 30 seconds of think time between interactions. In conversational mode, how many CICS tasks would be active during think time? In pseudo-conversational mode, how many tasks are active during think time? What CICS resources are consumed during think time in each mode?
### Exercise 7: HANDLE CONDITION vs. RESP
Rewrite the following HANDLE CONDITION approach using the RESP/RESP2 technique. Explain why the RESP approach is preferred in modern CICS programming.
```cobol
EXEC CICS HANDLE CONDITION
NOTFND(8100-NOT-FOUND)
DUPKEY(8200-DUPLICATE)
IOERR(8300-IO-ERROR)
LENGERR(8400-LENGTH-ERR)
END-EXEC
EXEC CICS READ FILE('CUSTFIL')
INTO(WS-CUST-RECORD)
RIDFLD(WS-CUST-KEY)
LENGTH(WS-RECORD-LEN)
END-EXEC
* If we reach here, the read was successful
PERFORM 5000-PROCESS-CUSTOMER
...
8100-NOT-FOUND.
MOVE 'Customer not found' TO WS-ERROR-MSG
PERFORM 9000-SEND-ERROR
.
8200-DUPLICATE.
...
Exercise 8: EIB Field Identification
For each of the following EIB (Execute Interface Block) fields, state its data type, what information it contains, and give a practical example of when a COBOL program would reference it.
- EIBCALEN
- EIBTRNID
- EIBDATE
- EIBTIME
- EIBTRMID
- EIBAID
- EIBRESP
- EIBFN
Tier 2: Application (Exercises 9-16)
Exercise 9: Complete Account Inquiry Program
Write a complete pseudo-conversational CICS COBOL program that implements an account inquiry. The program should:
- On first invocation (EIBCALEN = 0), send an empty inquiry screen with the cursor on the account number field
- On subsequent invocations, receive the map, validate the account number, read the VSAM file, and display account details
- Allow the user to enter a new account number to perform another inquiry
- Handle NOTFND, IOERR, and MAPFAIL conditions using the RESP technique
- Display meaningful error messages on the 23rd line of the screen
- Use a COMMAREA to preserve the current state and last account viewed
Include the BMS map definition, the generated copybook structure, and the COBOL source.
Exercise 10: Menu-Driven Transaction Router
Write a CICS COBOL program that displays a main menu and routes to different programs based on user selection:
- Option 1: Account Inquiry (XCTL to ACCTINQ)
- Option 2: Account Update (XCTL to ACCTUPD)
- Option 3: Transaction History (XCTL to TRANHIST)
- Option 4: New Account (LINK to ACCTNEW)
- Option 9: Exit (SEND TEXT goodbye message and RETURN without TRANSID)
Handle PF3 as an alternate exit key and PF12 to refresh the menu. Validate that the user enters a valid option number.
Exercise 11: CICS File Control Operations
Write a COBOL program fragment that performs the following VSAM KSDS file operations in CICS, with complete error handling for each:
- READ a record by primary key
- READ with UPDATE, modify a field, and REWRITE
- WRITE a new record (handle DUPREC)
- DELETE a record by primary key
- STARTBR at a partial key, READNEXT through matching records, then ENDBR
- RESETBR to reposition during a browse
For each operation, show the EXEC CICS command, the RESP check, and the error handling.
Exercise 12: Multi-Screen Navigation
Write a pseudo-conversational CICS program that manages navigation between three screens using a COMMAREA state machine:
- Screen 1: Customer search (enter name or ID)
- Screen 2: Customer list (display matching customers, allow selection)
- Screen 3: Customer detail (display full details of selected customer)
From Screen 3, PF3 returns to Screen 2 (the list). From Screen 2, PF3 returns to Screen 1 (the search). From Screen 1, PF3 exits the transaction. Design the COMMAREA to support this navigation, including preserving the search criteria and list position.
Exercise 13: AID Key Processing
Write a COBOL paragraph that processes all standard CICS Attention Identifier (AID) keys. The paragraph should handle:
- ENTER: Process the current screen input
- PF1: Display help
- PF3: Exit/return to previous screen
- PF5: Refresh current screen
- PF7: Scroll backward
- PF8: Scroll forward
- PF12: Cancel current operation
- CLEAR: Reset the screen
- PA1, PA2: Ignore (do not process)
Use DFHAID copybook values and explain why PA keys should be handled differently from PF keys.
Exercise 14: BMS Paging with Scrollable List
Write a CICS COBOL program that displays a scrollable list of account transactions using BMS. The program should:
- Retrieve up to 200 transactions from a VSAM file
- Display 15 transactions per page
- Support PF7 (page backward) and PF8 (page forward)
- Display "Page n of m" in the header
- Store the transaction data in the COMMAREA (or use temporary storage if too large)
- Highlight the most recent transaction in a different color
Include the BMS map definition for the list screen.
Exercise 15: CICS Temporary Storage Queue
Write a COBOL program that uses CICS Temporary Storage (TS) queues to share data between transactions. The program should:
- Write customer search results to a TS queue named with the terminal ID
- Read back the results one page at a time using ITEM numbers
- Delete the TS queue when the user exits
- Handle QIDERR (queue not found) and ITEMERR (item not found) conditions
- Use MAIN vs. AUXILIARY storage appropriately based on data size
EXEC CICS WRITEQ TS
QUEUE(WS-QUEUE-NAME)
FROM(WS-RESULT-RECORD)
LENGTH(WS-RESULT-LEN)
ITEM(WS-ITEM-NUM)
MAIN
RESP(WS-RESP)
END-EXEC
Exercise 16: Program-to-Program Communication
Write two CICS COBOL programs that communicate via COMMAREA:
Program A (ACCTMAIN): Accepts an account number from the user, builds a COMMAREA with the account number and a request code, and LINKs to Program B.
Program B (ACCTPROC): Receives the COMMAREA, reads the account file, populates the COMMAREA with account details, and GOBACKs.
After the LINK returns, Program A extracts the data from the COMMAREA and displays it on the screen.
Show both programs, the shared COMMAREA copybook, and explain the difference between LINK and XCTL for this scenario.
Tier 3: Analysis and Design (Exercises 17-22)
Exercise 17: Pseudo-Conversational State Design
A CICS transaction supports the following user workflow for account maintenance:
Search -> List -> Detail View -> Edit Mode -> Confirm Changes -> Success
|
+--> Cancel -> Detail View
Design the COMMAREA state machine to support this workflow. For each state transition: 1. Define the state name and numeric code 2. List what data must be preserved in the COMMAREA 3. Specify which AID keys trigger which transitions 4. Describe what processing occurs during the transition 5. Calculate the minimum COMMAREA size needed
Exercise 18: CICS Performance Analysis
A CICS region processes 5,000 transactions per minute. The average transaction involves: - 1 RECEIVE MAP (2 ms) - 2 FILE READ operations (5 ms each) - 1 FILE REWRITE (8 ms) - 1 SEND MAP (3 ms) - Network round-trip (15 ms)
In conversational mode, the average think time is 20 seconds. In pseudo-conversational mode, the task lifetime equals the processing time only.
Calculate: 1. The average task lifetime in conversational vs. pseudo-conversational mode 2. The maximum concurrent tasks in each mode 3. The CICS virtual storage consumed by tasks in each mode (assume 32 KB per task control block) 4. Why MAXTASK limits are critical in conversational mode
Exercise 19: Error Recovery Strategy
Design a comprehensive error handling strategy for a CICS banking application. Address:
- MAPFAIL: User presses Enter without typing anything
- NOTFND: Account number does not exist in the file
- DUPREC: Attempting to add a duplicate account
- LENGERR: Record length mismatch
- IOERR: Physical I/O error on the VSAM file
- PGMIDERR: Called program not found in CICS
- INVREQ: Invalid request (e.g., REWRITE without prior READ for UPDATE)
- DISABLED: File is disabled by a system administrator
For each condition, specify: - Whether the error is recoverable or fatal - The message to display to the user - Whether to log the error to a TS queue or TD queue - Whether the transaction should continue, retry, or terminate
Exercise 20: BMS Map Design for Complex Screen
Design a BMS map for a bank teller screen that contains:
- A header area with bank name, date/time, teller ID, and branch code
- A customer information section with name, address, phone, SSN (masked), and membership date
- A scrollable account list showing up to 8 accounts with account number, type, balance, and status
- A transaction entry area with amount, type dropdown (deposit/withdrawal/transfer), and memo field
- A function key legend at the bottom (PF1=Help, PF3=Exit, PF5=Refresh, PF7/8=Scroll)
- An error/information message line
Specify the ATTRB settings for each field (ASKIP for display, UNPROT for input, BRT for headers, NORM for data). Show the complete DFHMDI/DFHMDF macro definitions.
Exercise 21: COMMAREA vs. CHANNEL/CONTAINER Analysis
Compare the traditional COMMAREA approach with the newer CHANNEL/CONTAINER approach for passing data between CICS programs. For each scenario, recommend which approach is better and justify your choice:
- Passing 200 bytes of account data between two programs via LINK
- Passing a 50 KB customer record with embedded images
- Passing structured data (multiple independent data items) to a service program
- Maintaining state across pseudo-conversational iterations
- Calling a web service wrapper program that returns variable-length XML
Exercise 22: Transaction Abend Analysis
A CICS transaction ATFR abends with the following dump excerpt:
TRANSACTION ATFR ABEND ASRA AT OFFSET X'0001A4'
PROGRAM: ACCTXFER
EIBRESP: 0 EIBRESP2: 0 EIBFN: X'0602'
TASK: 00045892 TERM: PT42
COMMAREA LENGTH: 150
Answer: 1. What does ABEND code ASRA indicate? 2. What CICS function was in progress (EIBFN X'0602')? 3. What are the most likely causes of this abend? 4. How would you use the offset X'0001A4' to find the failing statement? 5. What preventive measures could avoid this type of abend?
Tier 4: Advanced Challenges (Exercises 23-30)
Exercise 23: Complete Pseudo-Conversational CRUD Application
Write a complete CICS COBOL application that performs all CRUD (Create, Read, Update, Delete) operations on a customer VSAM file. The application should include:
- A search screen that accepts customer ID or partial name
- A list screen showing matching results with selection capability
- A detail screen with view/edit toggle
- An add screen for new customers
- A delete confirmation screen
- Full error handling with user-friendly messages
- Optimistic concurrency control (detect if the record was modified by another user since it was read)
- All BMS map definitions and COMMAREA design
Exercise 24: CICS File Control with Alternate Index
Write a CICS COBOL program that supports browsing a customer file by two different keys:
- Primary key: Customer ID (KSDS primary key)
- Alternate key: Customer last name (alternate index, non-unique)
The program should: - Allow the user to choose which key to search by - Handle non-unique alternate key results (display all matches) - Use STARTBR/READNEXT/ENDBR for browse operations - Support forward and backward paging through results - Handle ENDFILE and NOTFND conditions during browse
Exercise 25: CICS Queue-Based Architecture
Design and implement a message queue processing pattern using CICS:
- A producer transaction reads teller entries from the screen and writes them to a Transient Data (TD) queue
- A consumer transaction is triggered automatically by the TD queue trigger level
- The consumer reads messages from the queue, validates them, and writes to the VSAM file
- A monitor transaction displays the queue depth and processing statistics
- Handle the case where the consumer falls behind (queue depth exceeds threshold)
Exercise 26: Dynamic BMS Screen Builder
Write a CICS COBOL program that builds screen output dynamically without a BMS map. Using SEND TEXT and SEND CONTROL, the program should:
- Build a report display screen with variable-length columns
- Support color attributes applied at runtime
- Handle screen overflow by splitting long output across multiple screens
- Allow the user to press PF7/PF8 to page through the output
- Compare the performance characteristics with the BMS SEND MAP approach
Exercise 27: CICS Security Implementation
Write a CICS COBOL program that implements application-level security:
- Check the CICS user ID from the EXEC CICS ASSIGN command
- Look up the user's authorization level in a VSAM security file
- Enable/disable menu options based on authorization level
- Modify BMS map attributes at runtime (protect fields the user cannot modify)
- Log all security-relevant events (access attempts, denied operations) to a TD queue
- Implement session timeout detection using ASKTIME and COMMAREA timestamps
Exercise 28: Cross-Transaction Resource Locking
Design a CICS COBOL application that handles the "browse and update" problem where multiple tellers may try to update the same account:
- When a teller reads an account for update, record a soft lock in a control file
- Display a warning if another teller has the same account locked
- Release the lock when the teller completes or cancels the update
- Implement a timeout mechanism to release stale locks (teller closed terminal)
- Handle the race condition where two tellers attempt to lock simultaneously
Exercise 29: CICS Web Service Integration
Write a CICS COBOL program that:
- Receives an HTTP request via the CICS web services infrastructure
- Parses the incoming JSON/XML payload
- Processes the banking operation (account inquiry, balance check)
- Constructs a JSON/XML response
- Sends the response back to the HTTP client
- Handles content type negotiation and HTTP status codes
Exercise 30: Complete Teller Application Architecture
Design the complete architecture for a CICS-based bank teller application. The system consists of:
- Main menu program (TELLMENU)
- Customer lookup program (CUSTLOOK)
- Account inquiry program (ACCTINQ)
- Transaction entry program (TRANENTY)
- Transaction posting program (TRANPOST)
- Balance adjustment program (BALADJ)
- Supervisor override program (SUPRAUTH)
- Audit logging program (AUDITLOG)
For each program, specify: - Whether it uses LINK, XCTL, or RETURN TRANSID - What data passes through COMMAREA - What CICS resources it uses (files, queues, programs) - Its error handling approach - A JCL fragment for compiling and deploying it to CICS
Tier 5: Research and Exploration (Exercises 31-38)
Exercise 31: CICS TS V6 Enhancements
Research the latest features in CICS Transaction Server V6.x. Investigate how these features affect COBOL programming: - Liberty JVM server integration - Cloud-native deployment - Threadsafe programming - JSON transformation - Event processing
Exercise 32: CICS and MQ Integration
Research how CICS COBOL programs interact with IBM MQ (formerly WebSphere MQ). Investigate: - EXEC CICS READQ and WRITEQ TD with MQ bridges - MQ trigger monitors and CICS transactions - Syncpoint coordination between CICS and MQ - Message-driven architecture patterns for banking
Exercise 33: CICS Transaction Gateway
Research how the CICS Transaction Gateway (CTG) allows external applications to invoke CICS programs. Investigate: - How a Java application calls a CICS COBOL program through CTG - COMMAREA and CHANNEL data mapping - Connection pooling and performance considerations - Real-world use cases in online banking and mobile apps
Exercise 34: CICS Monitoring and Tuning
Research CICS monitoring tools and techniques. Investigate: - CICS Statistics and Monitoring Facility (SMF 110 records) - How to identify slow transactions - Virtual storage analysis and tuning - MAXTASK, RUNAWAY, and SCANDELAY parameter effects - Tools: CICS Performance Analyzer, IBM OMEGAMON for CICS
Exercise 35: CICS and API Connect
Research how IBM API Connect can expose CICS transactions as REST APIs. How does a COBOL CICS program become a microservice? What transformations occur for data types? What about security (OAuth, API keys)?
Exercise 36: History of CICS
Research the history of CICS from its creation in 1968 to the present. How has the programming model evolved while maintaining backward compatibility with COBOL applications written in the 1970s?
Exercise 37: CICS Recovery and Restart
Research CICS recovery mechanisms for COBOL programs. Investigate: - Dynamic transaction backout (DTB) - Emergency restart vs. warm restart - EXEC CICS SYNCPOINT and SYNCPOINT ROLLBACK - Logging and journal records - How VSAM recoverable files interact with CICS recovery
Exercise 38: Testing CICS Programs Without CICS
Research approaches for testing CICS COBOL programs outside of a CICS environment: - IBM CICS Interdependency Analyzer - Micro Focus Enterprise Server CICS emulation - Mock/stub frameworks for EXEC CICS commands - Unit testing strategies for pseudo-conversational programs - Continuous integration pipelines for CICS applications