Exercises: CICS Fundamentals
Exercise 29.1: BMS Map Design (Introductory)
Design a BMS map definition for a MedClaim "Member Lookup" screen with the following layout:
Row 1: Title "MEDCLAIM MEMBER INQUIRY" (centered), Date and Time (right)
Row 3: Label "Member ID:" followed by input field (10 chars)
Row 5: Label "Member Name:" followed by display field (50 chars)
Row 7: Label "Date of Birth:" followed by display field (10 chars)
Row 9: Label "Plan Code:" followed by display field (4 chars)
Label "Plan Name:" followed by display field (30 chars)
Row 11: Label "Coverage Level:" followed by display field (15 chars)
Row 13: Label "Effective Date:" followed by display field (10 chars)
Label "Term Date:" followed by display field (10 chars)
Row 15: Label "Primary Care:" followed by display field (30 chars)
Row 21: Message line (60 chars, bright)
Row 23: "Enter=Lookup PF3=Exit PF5=Refresh"
Row 24: "Transaction: MINQ"
Requirements: 1. Write the complete DFHMSD, DFHMDI, and DFHMDF macros 2. The Member ID field should be unprotected with initial cursor position 3. All display fields should be protected and bright 4. Include stopper fields after the input field 5. Give meaningful names to all data fields (not labels)
Exercise 29.2: Pseudo-Conversational Flow Tracing (Introductory)
Trace through the following pseudo-conversational program and answer the questions below.
PROCEDURE DIVISION.
0000-MAIN.
EVALUATE TRUE
WHEN EIBCALEN = 0
PERFORM 1000-FIRST-TIME
WHEN OTHER
MOVE DFHCOMMAREA TO WS-COMMAREA
EVALUATE EIBAID
WHEN DFHENTER
EVALUATE WS-CA-STATE
WHEN 'M'
PERFORM 2000-PROCESS-SEARCH
WHEN 'D'
PERFORM 3000-PROCESS-UPDATE
END-EVALUATE
WHEN DFHPF3
EXEC CICS RETURN END-EXEC
WHEN OTHER
MOVE 'Invalid key' TO MSGO
PERFORM 1500-RESEND
END-EVALUATE
END-EVALUATE
GOBACK.
Questions: 1. What happens if the user types the transaction ID and presses Enter for the first time? 2. The user sees the initial map and enters data, then presses Enter. What COMMAREA state value determines which paragraph runs? 3. If WS-CA-STATE is 'D' and the user presses PF3, what happens? 4. What COMMAREA state would paragraph 2000 set before its RETURN to enable 3000 to run on the next Enter? 5. Could a user reach paragraph 3000 on the very first Enter after the initial map? Why or why not?
Exercise 29.3: CICS Error Handling (Intermediate)
Write the error handling logic for a CICS program that reads a VSAM KSDS file. Your code must handle the following conditions using the RESP/RESP2 approach:
| Condition | Action |
|---|---|
| NORMAL | Display the record data |
| NOTFND | Display "Record not found" message |
| DISABLED | Display "File is currently unavailable" and log the error |
| IOERR | Display "System error" and abend with code 'IOER' |
| LENGERR | Display "Record length mismatch" and log details |
| INVREQ | Display "Invalid request" and log RESP2 value |
| OTHER | Display generic error with RESP and RESP2 values |
Requirements: 1. Use DFHRESP symbolic names, not numeric values 2. Log errors to transient data queue 'CSMT' 3. Include the terminal ID (EIBTRMID) and transaction ID (EIBTRNID) in log messages 4. For abend conditions, send the error message to the user before abending
Exercise 29.4: Complete Inquiry Transaction (Intermediate)
Write a complete pseudo-conversational CICS program for a "Product Lookup" transaction (PINQ) that:
- Displays a screen with a Product Code input field
- When the user enters a code and presses Enter, looks up the product in a VSAM file
- Displays product details: code, description, price, quantity on hand, reorder level
- Handles Enter (lookup), PF3 (exit), Clear (reset)
- Validates that the product code is not empty
- Handles NOTFND with a friendly message
Deliverables: - BMS map definition - Complete COBOL program with pseudo-conversational logic - COMMAREA design with state management - Error handling for all CICS commands
Exercise 29.5: COMMAREA State Machine (Intermediate)
Design a COMMAREA and state management logic for a three-screen transaction:
- Screen 1: Search criteria entry (customer name, date range)
- Screen 2: Search results list (multiple rows)
- Screen 3: Detail view of a selected record
Draw a state diagram showing all possible transitions (which keys move between which screens). Then write the PROCEDURE DIVISION control flow that implements this state machine using EVALUATE.
Requirements: 1. Define the COMMAREA structure with a state field and data for each screen 2. Handle: Enter, PF3 (back/exit), PF7/PF8 (scroll on Screen 2), Clear 3. PF3 from Screen 3 returns to Screen 2; PF3 from Screen 2 returns to Screen 1; PF3 from Screen 1 exits 4. The COMMAREA must preserve the search criteria when navigating from Screen 2 back to Screen 1
Exercise 29.6: BMS Attribute Manipulation (Advanced)
Write a CICS program that dynamically changes field attributes based on data values:
- Display an account record with balance, status, and overdraft flag fields
- If balance is negative, change the balance field attribute to bright/red
- If status is 'F' (Frozen), change the status field to bright/red and display a warning
- If overdraft flag is 'Y', highlight the overdraft field
Hint: Use the attribute byte (the F field in the symbolic map) to change field appearance at runtime. DFHBMSCA copybook provides attribute constants.
COPY DFHBMSCA.
* Use DFHBMBRY for bright, DFHBMDAR for dark, etc.
Exercise 29.7: CICS Debugging Exercise (Advanced)
The following CICS program has five bugs. Find and fix each one:
IDENTIFICATION DIVISION.
PROGRAM-ID. BUGGY01.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY DFHAID.
01 WS-RESP PIC S9(8) COMP.
01 WS-COMMAREA PIC X(20).
01 WS-CA-LEN PIC S9(4) COMP VALUE 20.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(20).
PROCEDURE DIVISION.
IF EIBCALEN = 0
EXEC CICS
SEND MAP('MYMAP')
MAPSET('MYSET')
ERASE
END-EXEC
EXEC CICS
RETURN TRANSID('ABCD')
COMMAREA(WS-COMMAREA)
LENGTH(WS-CA-LEN)
END-EXEC
END-IF.
MOVE DFHCOMMAREA TO WS-COMMAREA.
EXEC CICS
RECEIVE MAP('MYMAP')
MAPSET('MYSET')
INTO(MYMAPI)
END-EXEC.
PERFORM PROCESS-INPUT.
EXEC CICS
SEND MAP('MYMAP')
MAPSET('MYSET')
FROM(MYMAPO)
DATAONLY
END-EXEC.
STOP RUN.
PROCESS-INPUT.
EVALUATE EIBAID
WHEN DFHENTER
PERFORM DO-LOOKUP
WHEN DFHPF3
STOP RUN
END-EVALUATE.
Identify and fix: 1. What happens after the first SEND MAP/RETURN if EIBCALEN is NOT zero? 2. What is wrong with the transaction ID? 3. What is missing from the map include? 4. Where is the FROM option on the first SEND MAP? 5. What must replace STOP RUN (two occurrences)?