Chapter 25 Exercises: Advanced CICS Programming

Tier 1: Recall (Exercises 1-7)

For each of the following scenarios, identify whether LINK or XCTL is the appropriate CICS program control command. Explain your reasoning.

a) A menu program transfers control to a detail inquiry program. The menu program is no longer needed. b) A transaction processing program calls a DB2 access module to read a customer record and needs the result returned. c) An account update program calls an audit logging subprogram, then continues processing. d) A wizard-style application moves from step 2 to step 3, with no need to return to step 2. e) A controller program calls a validation routine and then examines the COMMAREA for error messages.

Solution:

a) XCTL -- The menu program has completed its work and should free its storage. Control transfers to the detail program without return.

b) LINK -- The calling program needs the DB2 result to continue processing. LINK returns control to the caller.

c) LINK -- The main program must continue after the audit logging completes.

d) XCTL -- Step 2 is finished and step 3 takes over. No return is needed.

e) LINK -- The controller must regain control to examine the COMMAREA after the validation routine completes.


Exercise 2: TSQ vs TDQ Selection

For each of the following requirements, determine whether a Temporary Storage Queue (TSQ) or a Transient Data Queue (TDQ) is the better choice. State whether the TDQ should be intrapartition or extrapartition if applicable.

a) Storing browse results for a multi-page screen display b) Writing audit log records that must be processed by a triggered background transaction every 200 records c) Writing print output to a JES spool dataset d) Caching lookup data that multiple transactions on the same terminal read repeatedly e) Passing a batch of error messages to a downstream sequential file for overnight processing f) Storing intermediate calculation results that the same transaction reads back by item number

Solution:

a) TSQ -- Random access by item number is needed for paging forward and backward.

b) TDQ (Intrapartition) -- Trigger-level processing is only available with intrapartition TDQs. The trigger level would be set to 200.

c) TDQ (Extrapartition) -- Extrapartition TDQs map to external sequential datasets and are ideal for print/spool output.

d) TSQ -- TSQs support rereading (non-destructive reads) and random access by item number.

e) TDQ (Extrapartition) -- The requirement is to write to an external sequential file, which is exactly what extrapartition TDQs do.

f) TSQ -- Random access by item number and rereading capability make TSQs the right choice for scratchpad-style data.


Exercise 3: COMMAREA vs Channels/Containers

Given the following COMMAREA definition, identify which problems exist and explain how channels and containers would address them.

       01  WS-COMMAREA.
           05  CA-CUSTOMER-DATA    PIC X(10000).
           05  CA-TRANSACTION-LOG  PIC X(15000).
           05  CA-REPORT-BUFFER    PIC X(8000).

Solution:

The total COMMAREA size is 33,000 bytes, which exceeds the COMMAREA maximum of 32,763 bytes. This will cause a runtime error. Additionally, the single flat structure mixes three unrelated data areas, making the interface unclear and brittle.

Channels and containers solve both problems: - Each data area becomes a named container (CUST-DATA, TRANS-LOG, REPORT-BUF) within a channel. - Each container can hold up to approximately 500 MB, far exceeding the COMMAREA limit. - The named containers are self-documenting and can be independently versioned. - A receiving program can browse the channel to discover which containers were sent.


Exercise 4: CICS Error Response Codes

Match each DFHRESP value to its meaning and the most likely scenario that causes it:

DFHRESP Value Meaning Scenario
a) DFHRESP(NOTFND) 1) File is not available i) User lacks RACF authority to the transaction
b) DFHRESP(DUPREC) 2) Record not found ii) Program name specified in LINK does not exist in CSD
c) DFHRESP(DISABLED) 3) Duplicate key on write iii) READ with a key that does not exist in the VSAM KSDS
d) DFHRESP(NOTAUTH) 4) Security violation iv) WRITE to KSDS with a key that already exists
e) DFHRESP(PGMIDERR) 5) Resource is disabled v) File definition is DISABLED in CEMT

Solution:

a-2-iii, b-3-iv, c-5-v, d-4-i, e-2-ii (Note: PGMIDERR indicates the program was not found in the program definition, mapped to scenario ii.)


Exercise 5: CICS Pseudo-Conversational State

A banking inquiry application uses the following COMMAREA. Trace the values of CA-STATE and CA-ACCOUNT-NUM through the sequence of user interactions described below.

       01  WS-COMMAREA.
           05  CA-STATE            PIC X(02).
               88  ST-INITIAL     VALUE '00'.
               88  ST-MENU        VALUE '10'.
               88  ST-DETAIL      VALUE '20'.
               88  ST-CONFIRM     VALUE '30'.
           05  CA-ACCOUNT-NUM      PIC X(10).
           05  CA-ACTION-CODE      PIC X(01).

User interactions: 1. User enters transaction ID BINQ for the first time. 2. The menu screen appears. User types account number 0012345678 and presses Enter. 3. The detail screen appears showing account data. User presses PF3 to go back. 4. The menu screen reappears.

Solution:

  1. First invocation: EIBCALEN = 0, so CA-STATE = '00' (initial). Program sends menu map and issues EXEC CICS RETURN TRANSID('BINQ') COMMAREA(WS-COMMAREA) with CA-STATE = '10'.

  2. Second invocation: CA-STATE = '10' (menu). Program receives map, reads CA-ACCOUNT-NUM = '0012345678'. Program reads account from DB2/VSAM, sends detail map, and returns with CA-STATE = '20' and CA-ACCOUNT-NUM = '0012345678'.

  3. Third invocation: CA-STATE = '20' (detail). Program detects PF3 (EIBAID = DFHPF3). Program sends menu map and returns with CA-STATE = '10' and CA-ACCOUNT-NUM = '0012345678' (retained for convenience).

  4. The menu screen is displayed with the previous account number still available.


Exercise 6: CICS Web Service Basics

Identify the CICS resource definitions and API commands needed for each step when exposing a COBOL program as a RESTful JSON web service:

a) Mapping a URL pattern to a CICS program b) Receiving the HTTP request body in the COBOL program c) Sending an HTTP response with a JSON content type d) Automatically transforming a COBOL COMMAREA to/from JSON

Solution:

a) A URIMAP resource definition with USAGE(SERVER), the URL path pattern, and the target PROGRAM name.

b) EXEC CICS WEB RECEIVE INTO(WS-REQUEST-BODY) LENGTH(WS-LEN) MAXLENGTH(nnnnn).

c) EXEC CICS WEB SEND FROM(WS-RESPONSE) FROMLENGTH(WS-RESP-LEN) MEDIATYPE('application/json') STATUSCODE(200) STATUSTEXT('OK').

d) The DFHJS2LS utility generates a JSON transformer from a COBOL copybook. The URIMAP references a PIPELINE resource that includes the transformer. CICS automatically converts JSON to COMMAREA on input and COMMAREA to JSON on output.


Exercise 7: CICS Security Concepts

Answer the following questions about CICS security:

a) What RACF resource class controls which users can execute which CICS transactions? b) What is the difference between EXEC CICS VERIFY and EXEC CICS SIGNON? c) What CICS command allows a program to check if the current user is authorized to perform an action before attempting it? d) Name three levels at which a properly secured CICS application checks authorization.

Solution:

a) TCICSTRN is the RACF resource class for CICS transaction security.

b) VERIFY validates a userid/password combination without changing the task's identity. SIGNON authenticates the user and changes the security context for the terminal session.

c) EXEC CICS QUERY SECURITY RESTYPE(...) RESID(...) checks whether the current user is authorized for a specific resource.

d) Transaction level (can the user run this transaction?), resource level (can the user access this file or queue?), and business level (can the user perform this operation on this specific account, implemented in application code).


Tier 2: Understand (Exercises 8-14)

Exercise 8: COMMAREA Versioning Strategy

A CICS banking application has evolved through three versions. The original COMMAREA (version 1) contained 50 bytes. Version 2 added 30 bytes for branch data. Version 3 added 40 bytes for session management. During deployment, both version 2 and version 3 programs may be running simultaneously.

Write the COBOL code that handles version detection and migration when a version 2 COMMAREA arrives at a version 3 program. Your code must: - Detect the incoming version - Preserve all existing data - Initialize only the new version 3 fields - Update the version number

       01  WS-COMMAREA.
           05  CA-VERSION          PIC 9(04).
           05  CA-EYE-CATCHER     PIC X(08) VALUE 'BANKCA  '.
           05  CA-V1-DATA.
               10  CA-USER-ID     PIC X(08).
               10  CA-STATE       PIC X(02).
               10  CA-ACCOUNT     PIC X(10).
               10  CA-FILLER-V1   PIC X(22).
           05  CA-V2-DATA.
               10  CA-BRANCH-CD   PIC X(04).
               10  CA-ACCESS-LVL  PIC 9(01).
               10  CA-FILLER-V2   PIC X(25).
           05  CA-V3-DATA.
               10  CA-SESSION-TKN PIC X(32).
               10  CA-LAST-ACTIVE PIC S9(15) COMP-3.

Solution:

           MOVE DFHCOMMAREA TO WS-COMMAREA.

           EVALUATE CA-VERSION
               WHEN 1
                   INITIALIZE CA-V2-DATA
                   INITIALIZE CA-V3-DATA
                   MOVE 3 TO CA-VERSION
               WHEN 2
                   INITIALIZE CA-V3-DATA
                   MOVE 3 TO CA-VERSION
               WHEN 3
                   CONTINUE
               WHEN OTHER
                   IF CA-EYE-CATCHER NOT = 'BANKCA  '
                       PERFORM 9200-INVALID-COMMAREA
                   ELSE
                       PERFORM 9210-UNKNOWN-VERSION
                   END-IF
           END-EVALUATE.

The key insight is that INITIALIZE only affects the new fields. The existing CA-V1-DATA and CA-V2-DATA fields are already populated from the MOVE of DFHCOMMAREA and are left untouched.


Exercise 9: Multi-Page Browse with TSQ

A CICS program displays account transaction history with 15 lines per page. The user can press PF7 to page backward and PF8 to page forward. The TSQ contains 73 items (transaction records).

Answer the following:

a) How many total pages are there? b) If the user is on page 3 and presses PF8, what TSQ item numbers should be read? c) If the user is on page 5 and presses PF7, what TSQ item numbers should be read? d) Write the COBOL code to calculate the starting TSQ item number given a page number and page size. e) How should the program prevent the user from paging past the last page or before the first page?

Solution:

a) Total pages = CEILING(73 / 15) = 5 pages. (Pages 1-4 have 15 items each; page 5 has 13 items.)

b) PF8 from page 3 goes to page 4. Starting item = (4 - 1) * 15 + 1 = 46. Items 46 through 60.

c) PF7 from page 5 goes to page 4. Starting item = (4 - 1) * 15 + 1 = 46. Items 46 through 60.

d)

           COMPUTE WS-START-ITEM =
               (CA-CURRENT-PAGE - 1) * WS-PAGE-SIZE + 1.
           COMPUTE WS-END-ITEM =
               CA-CURRENT-PAGE * WS-PAGE-SIZE.
           IF WS-END-ITEM > WS-TOTAL-ITEMS
               MOVE WS-TOTAL-ITEMS TO WS-END-ITEM
           END-IF.

e) Before paging, check boundaries:

           IF EIBAID = DFHPF8
               IF CA-CURRENT-PAGE < WS-TOTAL-PAGES
                   ADD 1 TO CA-CURRENT-PAGE
               ELSE
                   MOVE 'Already on last page' TO WS-MSG
               END-IF
           END-IF.
           IF EIBAID = DFHPF7
               IF CA-CURRENT-PAGE > 1
                   SUBTRACT 1 FROM CA-CURRENT-PAGE
               ELSE
                   MOVE 'Already on first page' TO WS-MSG
               END-IF
           END-IF.

Exercise 10: Channel and Container Operations

Write the COBOL code for a CICS service program called ACCTBAL that receives a customer ID through a container named CUST-REQ on a channel named ACCT-CHAN, looks up the customer's account balances, and returns the results in a container named ACCT-RESP on the same channel.

The request structure:

       01  WS-REQUEST.
           05  WS-REQ-CUST-ID     PIC X(10).
           05  WS-REQ-TYPE        PIC X(01).
               88  REQ-CHECKING  VALUE 'C'.
               88  REQ-SAVINGS   VALUE 'S'.
               88  REQ-ALL       VALUE 'A'.

The response structure:

       01  WS-RESPONSE.
           05  WS-RESP-CODE       PIC 9(04).
           05  WS-RESP-MSG        PIC X(40).
           05  WS-CHECKING-BAL    PIC S9(11)V99 COMP-3.
           05  WS-SAVINGS-BAL     PIC S9(11)V99 COMP-3.

Solution:

       PROCEDURE DIVISION.
       0000-MAIN.
      * Retrieve the channel name
           EXEC CICS ASSIGN CHANNEL(WS-CHANNEL-NAME)
           END-EXEC.

           IF WS-CHANNEL-NAME = SPACES
               MOVE 9999 TO WS-RESP-CODE
               MOVE 'No channel provided' TO WS-RESP-MSG
               PERFORM 8000-SEND-RESPONSE
               EXEC CICS RETURN END-EXEC
           END-IF.

      * Get the request container
           EXEC CICS GET CONTAINER('CUST-REQ')
               CHANNEL(WS-CHANNEL-NAME)
               INTO(WS-REQUEST)
               FLENGTH(LENGTH OF WS-REQUEST)
               RESP(WS-CICS-RESP)
           END-EXEC.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
               MOVE 9998 TO WS-RESP-CODE
               MOVE 'Failed to read request container'
                   TO WS-RESP-MSG
               PERFORM 8000-SEND-RESPONSE
               EXEC CICS RETURN END-EXEC
           END-IF.

      * Look up account balances
           PERFORM 5000-LOOKUP-BALANCES.

      * Send response
           PERFORM 8000-SEND-RESPONSE.
           EXEC CICS RETURN END-EXEC.

       8000-SEND-RESPONSE.
           EXEC CICS PUT CONTAINER('ACCT-RESP')
               FROM(WS-RESPONSE)
               FLENGTH(LENGTH OF WS-RESPONSE)
               CHANNEL(WS-CHANNEL-NAME)
           END-EXEC.

Exercise 11: CICS-DB2 Error Handling

The following CICS-DB2 code has several error handling deficiencies. Identify each problem and write the corrected version.

           EXEC SQL
               SELECT ACCT_BAL, ACCT_STATUS
               INTO :WS-BALANCE, :WS-STATUS
               FROM ACCOUNTS
               WHERE ACCT_ID = :WS-ACCT-ID
           END-EXEC.

           MOVE WS-BALANCE TO DETAIL-BAL.
           MOVE WS-STATUS TO DETAIL-STATUS.

           EXEC CICS SEND MAP('DETAILM')
               MAPSET('DETAILP')
               FROM(DETAIL-MAPO)
               ERASE
           END-EXEC.

Solution:

Problems identified: 1. No check of SQLCODE after the SELECT. If SQLCODE = 100 (not found) or negative (error), the program moves garbage data to the map. 2. No RESP/RESP2 on the SEND MAP command. 3. No handling for DB2 connection loss (SQLCODE = -911, -913 for deadlock/timeout).

Corrected version:

           EXEC SQL
               SELECT ACCT_BAL, ACCT_STATUS
               INTO :WS-BALANCE, :WS-STATUS
               FROM ACCOUNTS
               WHERE ACCT_ID = :WS-ACCT-ID
           END-EXEC.

           EVALUATE TRUE
               WHEN SQLCODE = 0
                   MOVE WS-BALANCE TO DETAIL-BAL
                   MOVE WS-STATUS TO DETAIL-STATUS
               WHEN SQLCODE = 100
                   MOVE 'Account not found' TO DETAIL-MSG
                   MOVE SPACES TO DETAIL-BAL
                   MOVE SPACES TO DETAIL-STATUS
               WHEN SQLCODE = -911 OR -913
                   EXEC CICS SYNCPOINT ROLLBACK
                   END-EXEC
                   MOVE 'Resource busy - retry' TO DETAIL-MSG
               WHEN OTHER
                   MOVE SQLCODE TO WS-SQLCODE-DISPLAY
                   STRING 'DB2 error: ' WS-SQLCODE-DISPLAY
                       DELIMITED BY SIZE
                       INTO DETAIL-MSG
                   PERFORM 9300-LOG-DB2-ERROR
           END-EVALUATE.

           EXEC CICS SEND MAP('DETAILM')
               MAPSET('DETAILP')
               FROM(DETAIL-MAPO)
               ERASE
               RESP(WS-CICS-RESP)
               RESP2(WS-CICS-RESP2)
           END-EXEC.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
               PERFORM 9400-MAP-SEND-ERROR
           END-IF.

Exercise 12: Syncpoint and Two-Phase Commit

A CICS transaction transfers funds between two accounts. It performs the following operations:

  1. READ account A (DB2)
  2. READ account B (DB2)
  3. UPDATE account A balance (DB2 - debit)
  4. UPDATE account B balance (DB2 - credit)
  5. WRITE audit record (VSAM file)
  6. PUT message on MQ queue (for notification)

Answer the following:

a) If the program issues EXEC CICS SYNCPOINT after step 6, what resources are committed? b) If step 5 (VSAM write) fails and the program issues EXEC CICS SYNCPOINT ROLLBACK, what happens to the DB2 updates from steps 3 and 4? c) Why is two-phase commit necessary in this scenario? d) What happens if the CICS region crashes between step 4 and step 5, before any syncpoint?

Solution:

a) All resources are committed: the DB2 updates to both accounts (steps 3 and 4), the VSAM audit record (step 5), and the MQ message (step 6). SYNCPOINT commits across all resource managers.

b) The DB2 updates from steps 3 and 4 are rolled back. The account balances return to their original values. Any VSAM or MQ changes since the last syncpoint are also rolled back.

c) Two-phase commit is necessary because three different resource managers are involved: DB2, VSAM, and MQ. Without two-phase commit, a failure could leave DB2 committed but VSAM and MQ uncommitted, resulting in inconsistent data (the balances changed but no audit record exists).

d) CICS emergency restart replays the system log. Since no SYNCPOINT was issued, all changes since the task started are rolled back. The DB2 updates from steps 3 and 4 are undone. The task must be restarted from the beginning. This is the correct behavior -- it preserves atomicity.


Exercise 13: TDQ Trigger-Level Processing

Design a CICS audit logging system for a banking application. The system must: - Accept audit records from any transaction via a shared paragraph - Buffer audit records using a TDQ with trigger-level processing - Automatically start a background transaction when 50 audit records accumulate - The background transaction reads all queued records and writes them to a DB2 audit table

Write the DCT definition, the audit-writing paragraph (called by application transactions), and the skeleton of the triggered transaction.

Solution:

DCT Definition:

DESTID=BAUD
TYPE=INTRA
TRANSID=BAUP
TRIGLEV=50

Audit-writing paragraph (included in application programs):

       9000-WRITE-AUDIT.
           MOVE EIBTRNID TO AL-TRANS-ID.
           MOVE EIBTRMID TO AL-TERM-ID.
           EXEC CICS ASSIGN USERID(AL-USER-ID)
           END-EXEC.
           EXEC CICS ASKTIME ABSTIME(AL-TIMESTAMP)
           END-EXEC.
           MOVE WS-AUDIT-ACTION TO AL-ACTION.
           MOVE WS-AUDIT-DETAIL TO AL-DETAIL.

           EXEC CICS WRITEQ TD
               QUEUE('BAUD')
               FROM(WS-AUDIT-LOG)
               LENGTH(LENGTH OF WS-AUDIT-LOG)
               RESP(WS-RESP)
           END-EXEC.

           IF WS-RESP NOT = DFHRESP(NORMAL)
               MOVE 'Audit write failed' TO WS-ERROR-MSG
               PERFORM 9500-LOG-ERROR
           END-IF.

Triggered transaction skeleton (BAUP):

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BAUDPROC.

       PROCEDURE DIVISION.
       0000-MAIN.
           PERFORM 1000-READ-AUDIT-QUEUE
               UNTIL WS-QUEUE-EMPTY = 'Y'.
           EXEC CICS SYNCPOINT END-EXEC.
           EXEC CICS RETURN END-EXEC.

       1000-READ-AUDIT-QUEUE.
           EXEC CICS READQ TD
               QUEUE('BAUD')
               INTO(WS-AUDIT-LOG)
               LENGTH(WS-AUDIT-LEN)
               RESP(WS-RESP)
           END-EXEC.

           IF WS-RESP = DFHRESP(QZERO)
               MOVE 'Y' TO WS-QUEUE-EMPTY
           ELSE IF WS-RESP = DFHRESP(NORMAL)
               PERFORM 2000-INSERT-AUDIT-DB2
               ADD 1 TO WS-INSERT-COUNT
           ELSE
               PERFORM 9000-TDQ-ERROR
           END-IF.

Exercise 14: RESP/RESP2 Error Handling Pattern

Rewrite the following code, which uses the older HANDLE CONDITION approach, to use the modern RESP/RESP2 pattern. The program reads a customer record from a VSAM KSDS, updates the balance, and rewrites the record.

           EXEC CICS HANDLE CONDITION
               NOTFND(8000-NOT-FOUND)
               DUPREC(8100-DUPLICATE)
               DISABLED(8200-FILE-DISABLED)
               ERROR(9000-GENERAL-ERROR)
           END-EXEC.

           EXEC CICS READ FILE('CUSTFILE')
               INTO(WS-CUST-REC)
               RIDFLD(WS-CUST-KEY)
               LENGTH(WS-REC-LEN)
               UPDATE
           END-EXEC.

           ADD WS-DEPOSIT TO CUST-BALANCE.

           EXEC CICS REWRITE FILE('CUSTFILE')
               FROM(WS-CUST-REC)
               LENGTH(WS-REC-LEN)
           END-EXEC.

Solution:

           EXEC CICS READ FILE('CUSTFILE')
               INTO(WS-CUST-REC)
               RIDFLD(WS-CUST-KEY)
               LENGTH(WS-REC-LEN)
               UPDATE
               RESP(WS-RESP)
               RESP2(WS-RESP2)
           END-EXEC.

           EVALUATE WS-RESP
               WHEN DFHRESP(NORMAL)
                   CONTINUE
               WHEN DFHRESP(NOTFND)
                   PERFORM 8000-NOT-FOUND
                   GO TO 0000-EXIT
               WHEN DFHRESP(DISABLED)
                   PERFORM 8200-FILE-DISABLED
                   GO TO 0000-EXIT
               WHEN OTHER
                   PERFORM 9000-GENERAL-ERROR
                   GO TO 0000-EXIT
           END-EVALUATE.

           ADD WS-DEPOSIT TO CUST-BALANCE.

           EXEC CICS REWRITE FILE('CUSTFILE')
               FROM(WS-CUST-REC)
               LENGTH(WS-REC-LEN)
               RESP(WS-RESP)
               RESP2(WS-RESP2)
           END-EXEC.

           IF WS-RESP NOT = DFHRESP(NORMAL)
               EVALUATE WS-RESP
                   WHEN DFHRESP(NOSPACE)
                       PERFORM 8300-FILE-FULL
                   WHEN DFHRESP(IOERR)
                       PERFORM 9100-IO-ERROR
                   WHEN OTHER
                       PERFORM 9000-GENERAL-ERROR
               END-EVALUATE
           END-IF.

The modern approach is superior because: (1) control flow is explicit and local rather than relying on non-local GOTOs through HANDLE CONDITION, (2) each command has its own tailored error handling, and (3) the code is easier to read, debug, and maintain.


Tier 3: Apply (Exercises 15-22)

Exercise 15: Complete Account Inquiry Program

Write a complete CICS pseudo-conversational program that performs a bank account inquiry. The program must:

  1. Display a map with an account number input field on first entry
  2. Receive the account number, validate it (10 digits, numeric)
  3. Read the account record from a VSAM KSDS (ACCTFILE)
  4. Display account details (account number, customer name, account type, balance, last activity date)
  5. Allow the user to press PF3 to return to the menu or Enter to inquire on another account
  6. Use RESP/RESP2 error handling on all CICS commands
  7. Store state in a COMMAREA

Account record layout:

       01  ACCT-RECORD.
           05  ACCT-NUMBER         PIC X(10).
           05  ACCT-CUST-NAME     PIC X(30).
           05  ACCT-TYPE          PIC X(01).
               88  ACCT-CHECKING  VALUE 'C'.
               88  ACCT-SAVINGS   VALUE 'S'.
               88  ACCT-MONEY-MKT VALUE 'M'.
           05  ACCT-BALANCE       PIC S9(11)V99 COMP-3.
           05  ACCT-LAST-ACTIVITY PIC X(10).
           05  ACCT-STATUS        PIC X(01).
           05  ACCT-FILLER        PIC X(45).

Solution:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ACCTINQ.

       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01  WS-COMMAREA.
           05  CA-STATE            PIC X(02).
               88  ST-INITIAL     VALUE '00'.
               88  ST-MENU        VALUE '10'.
               88  ST-DETAIL      VALUE '20'.
           05  CA-ACCOUNT-NUM      PIC X(10).

       01  WS-RESP                 PIC S9(08) COMP.
       01  WS-RESP2                PIC S9(08) COMP.
       01  WS-REC-LEN              PIC S9(04) COMP VALUE 100.

       01  ACCT-RECORD.
           05  ACCT-NUMBER         PIC X(10).
           05  ACCT-CUST-NAME     PIC X(30).
           05  ACCT-TYPE          PIC X(01).
           05  ACCT-BALANCE       PIC S9(11)V99 COMP-3.
           05  ACCT-LAST-ACTIVITY PIC X(10).
           05  ACCT-STATUS        PIC X(01).
           05  ACCT-FILLER        PIC X(45).

       COPY INQUIRM.

       LINKAGE SECTION.
       01  DFHCOMMAREA             PIC X(12).

       PROCEDURE DIVISION.
       0000-MAIN.
           IF EIBCALEN = ZERO
               PERFORM 1000-FIRST-TIME
           ELSE
               MOVE DFHCOMMAREA TO WS-COMMAREA
               EVALUATE TRUE
                   WHEN ST-MENU
                       PERFORM 2000-PROCESS-MENU
                   WHEN ST-DETAIL
                       PERFORM 3000-PROCESS-DETAIL
                   WHEN OTHER
                       PERFORM 1000-FIRST-TIME
               END-EVALUATE
           END-IF.
           EXEC CICS RETURN
               TRANSID('AINQ')
               COMMAREA(WS-COMMAREA)
               LENGTH(LENGTH OF WS-COMMAREA)
           END-EXEC.

       1000-FIRST-TIME.
           MOVE LOW-VALUES TO INQUIR-MAPO.
           EXEC CICS SEND MAP('INQUIRM')
               MAPSET('INQUIRP')
               FROM(INQUIR-MAPO)
               ERASE
               RESP(WS-RESP)
           END-EXEC.
           SET ST-MENU TO TRUE.

       2000-PROCESS-MENU.
           IF EIBAID = DFHPF3
               EXEC CICS XCTL PROGRAM('MAINMENU')
               END-EXEC
           END-IF.

           EXEC CICS RECEIVE MAP('INQUIRM')
               MAPSET('INQUIRP')
               INTO(INQUIR-MAPI)
               RESP(WS-RESP)
           END-EXEC.

           IF WS-RESP NOT = DFHRESP(NORMAL)
               PERFORM 1000-FIRST-TIME
               GO TO 0000-EXIT
           END-IF.

           MOVE ACCT-NUMI TO CA-ACCOUNT-NUM.
           PERFORM 2100-VALIDATE-ACCOUNT.
           IF WS-VALID = 'N'
               GO TO 0000-EXIT
           END-IF.

           EXEC CICS READ FILE('ACCTFILE')
               INTO(ACCT-RECORD)
               RIDFLD(CA-ACCOUNT-NUM)
               LENGTH(WS-REC-LEN)
               RESP(WS-RESP)
               RESP2(WS-RESP2)
           END-EXEC.

           EVALUATE WS-RESP
               WHEN DFHRESP(NORMAL)
                   PERFORM 2200-DISPLAY-DETAIL
               WHEN DFHRESP(NOTFND)
                   MOVE 'Account not found' TO MSG-TEXTO
                   PERFORM 2300-SEND-MENU-ERROR
               WHEN OTHER
                   MOVE 'File read error' TO MSG-TEXTO
                   PERFORM 2300-SEND-MENU-ERROR
           END-EVALUATE.

       2100-VALIDATE-ACCOUNT.
           MOVE 'Y' TO WS-VALID.
           IF CA-ACCOUNT-NUM = SPACES
               MOVE 'N' TO WS-VALID
               MOVE 'Account number required' TO MSG-TEXTO
               PERFORM 2300-SEND-MENU-ERROR
           END-IF.
           INSPECT CA-ACCOUNT-NUM TALLYING WS-NUM-COUNT
               FOR ALL SPACES.
           IF FUNCTION LENGTH(FUNCTION TRIM(
               CA-ACCOUNT-NUM)) NOT = 10
               MOVE 'N' TO WS-VALID
               MOVE 'Account must be 10 digits'
                   TO MSG-TEXTO
               PERFORM 2300-SEND-MENU-ERROR
           END-IF.

       2200-DISPLAY-DETAIL.
           MOVE LOW-VALUES TO DETAIL-MAPO.
           MOVE ACCT-NUMBER TO DET-ACCTO.
           MOVE ACCT-CUST-NAME TO DET-NAMEO.
           MOVE ACCT-BALANCE TO DET-BALO.
           MOVE ACCT-LAST-ACTIVITY TO DET-DATEO.
           EXEC CICS SEND MAP('DETAILM')
               MAPSET('INQUIRP')
               FROM(DETAIL-MAPO)
               ERASE
               RESP(WS-RESP)
           END-EXEC.
           SET ST-DETAIL TO TRUE.

       2300-SEND-MENU-ERROR.
           EXEC CICS SEND MAP('INQUIRM')
               MAPSET('INQUIRP')
               FROM(INQUIR-MAPO)
               DATAONLY
               RESP(WS-RESP)
           END-EXEC.
           SET ST-MENU TO TRUE.

       3000-PROCESS-DETAIL.
           IF EIBAID = DFHPF3
               PERFORM 1000-FIRST-TIME
           ELSE
               PERFORM 1000-FIRST-TIME
           END-IF.

       0000-EXIT.
           EXIT.

Exercise 16: TSQ-Based Multi-Page Browse

Write the key paragraphs for a CICS program that implements a multi-page browse of transaction history for a bank account. The program should:

  1. On first entry, execute a DB2 query to retrieve all transactions for the account
  2. Write each transaction record to a TSQ named with the terminal ID prefix
  3. Display 12 transactions per page
  4. Support PF7 (page back), PF8 (page forward), and PF3 (exit)
  5. Delete the TSQ when the user exits

Include the TSQ naming convention, the page calculation logic, and the PF key handling.

Hint: Structure the COMMAREA with page number, total items, and TSQ name.


Exercise 17: HANDLE ABEND with Recovery

Write a CICS program fragment that performs a fund transfer between two accounts. Implement error recovery using EXEC CICS HANDLE ABEND LABEL. If an abend occurs during the transfer:

  1. Log the error details to a TDQ
  2. Send an error screen to the user
  3. Issue a SYNCPOINT ROLLBACK to undo partial changes

Include PUSH HANDLE and POP HANDLE to isolate the abend handling for the transfer section from the rest of the program.

Hint: The transfer involves a READ UPDATE of account A, a READ UPDATE of account B, a REWRITE of both, and a WRITE to an audit file.


Exercise 18: Channel-Based Service Architecture

Design a CICS service that processes loan applications. The calling program creates a channel with three containers:

  • LOAN-REQUEST: Applicant details and loan amount
  • CREDIT-SCORE: Pre-fetched credit score data
  • COLLATERAL: Collateral information (optional)

The service program must: 1. Determine which containers were sent by browsing the channel 2. Process the loan application using available data 3. Return a LOAN-DECISION container with approval/denial and terms 4. Return an AUDIT-TRAIL container with processing details

Write the COBOL code for both the calling program and the skeleton of the service program.

Solution:

Calling program:

      * Build channel with containers
           EXEC CICS PUT CONTAINER('LOAN-REQUEST')
               FROM(WS-LOAN-REQ)
               FLENGTH(LENGTH OF WS-LOAN-REQ)
               CHANNEL('LOANPROC-CHAN')
           END-EXEC.

           EXEC CICS PUT CONTAINER('CREDIT-SCORE')
               FROM(WS-CREDIT-DATA)
               FLENGTH(LENGTH OF WS-CREDIT-DATA)
               CHANNEL('LOANPROC-CHAN')
           END-EXEC.

      * Collateral is optional
           IF WS-HAS-COLLATERAL = 'Y'
               EXEC CICS PUT CONTAINER('COLLATERAL')
                   FROM(WS-COLLATERAL)
                   FLENGTH(LENGTH OF WS-COLLATERAL)
                   CHANNEL('LOANPROC-CHAN')
               END-EXEC
           END-IF.

      * Link to service
           EXEC CICS LINK PROGRAM('LOANEVAL')
               CHANNEL('LOANPROC-CHAN')
               RESP(WS-RESP)
           END-EXEC.

      * Get decision
           EXEC CICS GET CONTAINER('LOAN-DECISION')
               CHANNEL('LOANPROC-CHAN')
               INTO(WS-DECISION)
               FLENGTH(WS-DEC-LEN)
           END-EXEC.

Service program skeleton:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. LOANEVAL.
       PROCEDURE DIVISION.
       0000-MAIN.
           EXEC CICS ASSIGN CHANNEL(WS-CHAN-NAME)
           END-EXEC.

      * Get required container
           EXEC CICS GET CONTAINER('LOAN-REQUEST')
               CHANNEL(WS-CHAN-NAME)
               INTO(WS-LOAN-REQ)
               FLENGTH(WS-LEN)
               RESP(WS-RESP)
           END-EXEC.
           IF WS-RESP NOT = DFHRESP(NORMAL)
               PERFORM 9000-MISSING-REQUEST
               EXEC CICS RETURN END-EXEC
           END-IF.

      * Get credit score (required)
           EXEC CICS GET CONTAINER('CREDIT-SCORE')
               CHANNEL(WS-CHAN-NAME)
               INTO(WS-CREDIT-DATA)
               FLENGTH(WS-LEN)
               RESP(WS-RESP)
           END-EXEC.

      * Check for optional collateral by browsing
           MOVE 'N' TO WS-HAS-COLLATERAL.
           EXEC CICS STARTBROWSE CONTAINER
               CHANNEL(WS-CHAN-NAME)
               BROWSETOKEN(WS-BTOKEN)
           END-EXEC.
           PERFORM UNTIL WS-BROWSE-DONE = 'Y'
               EXEC CICS GETNEXT CONTAINER(WS-CONT-NAME)
                   BROWSETOKEN(WS-BTOKEN)
                   RESP(WS-RESP)
               END-EXEC
               IF WS-RESP = DFHRESP(END)
                   MOVE 'Y' TO WS-BROWSE-DONE
               ELSE
                   IF WS-CONT-NAME = 'COLLATERAL'
                       MOVE 'Y' TO WS-HAS-COLLATERAL
                   END-IF
               END-IF
           END-PERFORM.
           EXEC CICS ENDBROWSE CONTAINER
               BROWSETOKEN(WS-BTOKEN)
           END-EXEC.

           IF WS-HAS-COLLATERAL = 'Y'
               EXEC CICS GET CONTAINER('COLLATERAL')
                   CHANNEL(WS-CHAN-NAME)
                   INTO(WS-COLLATERAL)
                   FLENGTH(WS-LEN)
               END-EXEC
           END-IF.

      * Process loan decision
           PERFORM 5000-EVALUATE-LOAN.

      * Return results
           EXEC CICS PUT CONTAINER('LOAN-DECISION')
               FROM(WS-DECISION)
               FLENGTH(LENGTH OF WS-DECISION)
               CHANNEL(WS-CHAN-NAME)
           END-EXEC.

           EXEC CICS PUT CONTAINER('AUDIT-TRAIL')
               FROM(WS-AUDIT)
               FLENGTH(LENGTH OF WS-AUDIT)
               CHANNEL(WS-CHAN-NAME)
           END-EXEC.

           EXEC CICS RETURN END-EXEC.

Exercise 19: Web Service Request/Response

Write a CICS COBOL program that acts as an HTTP server endpoint. The program receives a JSON request containing an account ID, performs an account balance inquiry, and returns a JSON response. The program must:

  1. Receive the HTTP request body
  2. Parse the account ID from the request (assume a simple fixed-format JSON)
  3. Read the account from a VSAM file
  4. Build a JSON response with account number, name, balance, and status
  5. Send the HTTP response with appropriate status codes (200 for success, 404 for not found, 500 for error)

Hint: Use EXEC CICS WEB RECEIVE and EXEC CICS WEB SEND with MEDIATYPE('application/json').


A front-end CICS region (CICP) needs to call a back-end service program (DBSERV) running on a separate CICS region (CICD). The service program accesses DB2 and must not perform any terminal I/O.

Write: a) The LINK command in the front-end program, including SYSID and SYNCONRETURN b) The service program skeleton that processes the COMMAREA request c) Error handling for the case where the remote region is unavailable (SYSIDERR response)

Solution:

a) Front-end LINK:

           EXEC CICS LINK PROGRAM('DBSERV')
               COMMAREA(WS-SERVICE-REQ)
               LENGTH(LENGTH OF WS-SERVICE-REQ)
               SYSID('CICD')
               SYNCONRETURN
               RESP(WS-RESP)
               RESP2(WS-RESP2)
           END-EXEC.

           EVALUATE WS-RESP
               WHEN DFHRESP(NORMAL)
                   PERFORM 3000-PROCESS-RESPONSE
               WHEN DFHRESP(SYSIDERR)
                   MOVE 'Remote region unavailable'
                       TO WS-ERROR-MSG
                   PERFORM 8000-DISPLAY-ERROR
               WHEN DFHRESP(PGMIDERR)
                   MOVE 'Service program not found'
                       TO WS-ERROR-MSG
                   PERFORM 8000-DISPLAY-ERROR
               WHEN OTHER
                   MOVE 'DPL call failed' TO WS-ERROR-MSG
                   PERFORM 9000-UNEXPECTED-ERROR
           END-EVALUATE.

b) Service program skeleton:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. DBSERV.
      * DPL-capable: No terminal I/O commands
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-SERVICE-REQ.
           05  SRV-REQUEST-TYPE   PIC X(04).
           05  SRV-ACCOUNT-ID    PIC X(10).
           05  SRV-RESP-CODE     PIC 9(04).
           05  SRV-BALANCE       PIC S9(11)V99 COMP-3.
           05  SRV-CUST-NAME     PIC X(30).
       LINKAGE SECTION.
       01  DFHCOMMAREA           PIC X(60).
       PROCEDURE DIVISION.
           MOVE DFHCOMMAREA TO WS-SERVICE-REQ.
           EVALUATE SRV-REQUEST-TYPE
               WHEN 'INQY'
                   PERFORM 1000-INQUIRY
               WHEN 'UPDT'
                   PERFORM 2000-UPDATE
               WHEN OTHER
                   MOVE 9999 TO SRV-RESP-CODE
           END-EVALUATE.
           MOVE WS-SERVICE-REQ TO DFHCOMMAREA.
           EXEC CICS RETURN END-EXEC.

c) The SYSIDERR handling is shown in part (a). Additionally, the front-end should implement retry logic:

           MOVE 0 TO WS-RETRY-COUNT.
           PERFORM 2500-CALL-REMOTE
               UNTIL WS-CALL-OK = 'Y'
               OR WS-RETRY-COUNT > 2.

       2500-CALL-REMOTE.
           EXEC CICS LINK PROGRAM('DBSERV')
               COMMAREA(WS-SERVICE-REQ)
               LENGTH(LENGTH OF WS-SERVICE-REQ)
               SYSID('CICD')
               SYNCONRETURN
               RESP(WS-RESP)
           END-EXEC.
           IF WS-RESP = DFHRESP(NORMAL)
               MOVE 'Y' TO WS-CALL-OK
           ELSE
               ADD 1 TO WS-RETRY-COUNT
               IF WS-RETRY-COUNT <= 2
                   EXEC CICS DELAY
                       FOR SECONDS(2)
                   END-EXEC
               END-IF
           END-IF.

Exercise 21: CICS Debugging Exercise

A CICS program is experiencing the following symptoms. For each symptom, identify the most likely cause and the CICS tool you would use to diagnose it.

a) The program sends a map but the screen appears blank (no data fields displayed). b) Transaction XINQ abends with AEIO (program not found). c) A TSQ read returns QIDERR (queue not found) even though the browse program wrote to it. d) A VSAM file READ returns DISABLED. e) After a NEWCOPY, the old version of the program still seems to execute.

Solution:

a) Cause: The symbolic map was not initialized to LOW-VALUES before populating fields, or the fields were moved but the map was sent with MAPONLY instead of DATAONLY or both. Tool: CEDF to step through the SEND MAP command and examine the symbolic map contents.

b) Cause: The program is not defined in the CSD (CICS System Definition) for this CICS region, or the program name is misspelled. Tool: CEMT INQUIRE PROGRAM(XINQPGM) to check if the program is defined and enabled. If not found, check the CSD with CEDA.

c) Cause: The TSQ name does not match between the browse program and the read program. Often caused by a terminal ID mismatch in the TSQ naming convention (the triggered background transaction has a different EIBTRMID than the terminal transaction). Tool: CEBR to browse TSQs and verify the actual queue name. CEDF to examine the queue name passed to READQ TS.

d) Cause: The file definition is set to DISABLED status, possibly due to a batch job closing the VSAM dataset or an operator action. Tool: CEMT INQUIRE FILE(filename) to check the status. CEMT SET FILE(filename) ENABLED OPEN to re-enable it.

e) Cause: The program may be a link-edited part of another load module, so NEWCOPY on the individual program has no effect. Or the NEWCOPY was issued for the wrong program name. Tool: CEMT INQUIRE PROGRAM(pgmname) to verify the NEWCOPY timestamp. Check if the program is statically linked into a larger module.


Exercise 22: Performance Optimization

Review the following CICS code and identify at least five performance problems. For each, explain the issue and provide the optimized code.

           PERFORM 10 TIMES
               EXEC CICS WRITEQ TS
                   QUEUE(WS-TSQ-NAME)
                   FROM(WS-RECORD(WS-IDX))
                   LENGTH(500)
               END-EXEC
               ADD 1 TO WS-IDX
           END-PERFORM.

           EXEC CICS SEND MAP('BIGMAP')
               MAPSET('BIGSET')
               FROM(BIG-MAPO)
               ERASE
           END-EXEC.

           EXEC CICS LINK PROGRAM('VALIDATE')
               COMMAREA(WS-LARGE-COMM)
               LENGTH(30000)
           END-EXEC.

           EXEC CICS GETMAIN SET(ADDRESS OF WS-BUFFER)
               FLENGTH(1000000)
               SHARED
           END-EXEC.

Hint: Consider TSQ writes, map sending, COMMAREA size, GETMAIN usage, and RESP handling.


Tier 4: Analyze (Exercises 23-29)

Exercise 23: State Machine Design for Loan Application

Design a complete CICS state machine for a loan application workflow with the following screens:

  1. Customer selection (enter customer ID)
  2. Loan details entry (amount, term, rate)
  3. Collateral entry (property, vehicle, or other)
  4. Review screen (display all entered data)
  5. Confirmation screen (approve or reject the application)
  6. Completion screen (show application number)

Define the state transitions (which screen can go to which), the COMMAREA structure needed to support the entire workflow (including backward navigation), and the EVALUATE statement that dispatches based on state and AID key.

Hint: Consider what happens when the user presses PF3 on any screen -- the program should navigate back one level, not exit the application.


Exercise 24: CICS-DB2 Connection Pooling Analysis

A high-volume banking CICS region processes 5,000 transactions per second. Each transaction executes two SQL statements. The DB2CONN resource is configured with:

THREADLIMIT(200)
THREADWAIT(YES)

Each SQL statement takes an average of 2 milliseconds. Each transaction uses a pool thread.

a) Calculate the average number of concurrent threads needed. b) Is THREADLIMIT(200) sufficient? Show your work. c) What happens when all 200 threads are in use and a new transaction arrives (given THREADWAIT(YES))? d) What would happen if THREADWAIT(NO) were configured instead? e) Recommend a THREADLIMIT value with a 50% safety margin and justify your answer.

Hint: Think about Little's Law: L = arrival_rate * service_time.


Exercise 25: Multi-Region Architecture Design

A national bank needs to design a CICS architecture to serve customers across four geographic regions. Requirements:

  • Each region has its own DB2 database with regional account data
  • A customer in any region must be able to inquire on accounts in any other region
  • Fund transfers between regions must be atomic (all-or-nothing)
  • The system must handle 20,000 concurrent users

Design the CICS architecture, including: a) How many CICS regions and what types (AOR, TOR, FOR) b) How DPL (Distributed Program Link) connects the regions c) How cross-region fund transfers maintain atomicity d) How to handle the failure of one region without affecting the others

Hint: Consider a CICSPlex with Terminal Owning Regions (TOR) and Application Owning Regions (AOR).


Exercise 26: TSQ vs Container Performance Comparison

An application must pass 200 transaction records from a browse program to a detail processing program. Each record is 500 bytes. Compare two approaches:

Approach A: TSQ-based Write 200 records to a TSQ, store the TSQ name in the COMMAREA, LINK to the processing program, which reads the TSQ.

Approach B: Channel/Container-based Pack all 200 records into a single container (100,000 bytes), attach it to a channel, and LINK with the channel.

Analyze: a) Number of CICS API calls for each approach b) Storage implications c) Cleanup requirements d) What happens if the processing program abends e) Which approach is better and why


Exercise 27: Security Audit Design

Design a comprehensive security audit system for a CICS banking application. The system must:

  1. Log every transaction initiation with user ID, terminal ID, transaction code, and timestamp
  2. Log every file access (READ, WRITE, REWRITE, DELETE) with the file name, key, and operation
  3. Log every security check failure with the resource that was denied
  4. Detect and alert on suspicious patterns (same user accessing more than 50 different accounts in one hour)
  5. Store audit data for 7 years to meet regulatory requirements

Address the following: a) What CICS mechanism captures each type of event? b) How do you avoid performance impact on production transactions? c) How do you store 7 years of audit data efficiently? d) How do you implement the suspicious pattern detection?

Hint: Consider TDQs with trigger-level processing, auxiliary TSQs, and the CICS event processing framework.


Exercise 28: Migration from COMMAREA to Channels

A large CICS application has 45 programs that communicate using a shared COMMAREA copybook of 28,000 bytes. The development team wants to migrate to channels and containers. The COMMAREA has grown organically and contains sections used by different subsets of programs.

Design a migration strategy that: a) Allows gradual migration (not all 45 programs at once) b) Supports a transition period where some programs use COMMAREA and others use channels c) Minimizes the risk of data loss during the transition d) Provides a rollback plan if problems arise

Hint: Consider writing a "bridge" program that converts between COMMAREA and containers.


Exercise 29: Capacity Planning for Web Services

A bank is exposing CICS transactions as REST APIs through CICS web support. The existing CICS region handles 3,000 3270-terminal transactions per second. The new REST API is expected to add 2,000 requests per second, each requiring one LINK to a back-end program and one DB2 query.

Analyze: a) What additional CICS resources are needed (threads, connections, storage)? b) How does the HTTP protocol affect CICS task management differently from 3270 terminals? c) What URIMAP and PIPELINE resources are needed? d) Should the REST API traffic use the same CICS region or a separate one? Justify your answer. e) What monitoring metrics should be tracked to detect capacity problems?


Tier 5: Create (Exercises 30-34)

Exercise 30: Complete Online Banking Application

Design and write the COBOL code for a CICS online banking application with the following transactions:

  1. BKMU -- Main menu (account inquiry, transfer, history, logout)
  2. BKIN -- Account inquiry (display balance, account type, last transaction)
  3. BKTR -- Fund transfer (between two accounts with validation)
  4. BKHI -- Transaction history (multi-page browse using TSQ)

For each transaction, define: - The BMS map fields - The COMMAREA structure - The state machine transitions - The VSAM and/or DB2 access patterns - The error handling strategy

Write complete COBOL source for at least the BKIN (account inquiry) and BKTR (fund transfer) transactions. The fund transfer must use SYNCPOINT to ensure atomicity.

Hint: The fund transfer must handle the case where the source account has insufficient funds and where the two accounts are in different VSAM files.


Exercise 31: CICS Web Service Gateway

Design and implement a CICS COBOL program that acts as a gateway between RESTful web clients and existing CICS transactions. The gateway must:

  1. Accept HTTP POST requests with JSON payloads
  2. Parse the JSON to determine which back-end transaction to invoke
  3. Build the appropriate COMMAREA for the back-end program
  4. LINK to the back-end program
  5. Convert the COMMAREA response back to JSON
  6. Return the HTTP response with appropriate status codes and headers

The gateway should support at least three back-end operations: - Account inquiry (ACCTINQ) - Balance update (ACCTUPD) - Customer lookup (CUSTLKP)

Write the complete COBOL program and define the URIMAP and PIPELINE resource definitions.


Exercise 32: Automated Test Harness for CICS Programs

Design a CICS testing framework that:

  1. Reads test case definitions from a VSAM file (input COMMAREA values and expected output)
  2. Dynamically LINKs to the program under test with the input COMMAREA
  3. Compares the actual output COMMAREA to expected values field by field
  4. Writes test results to a TSQ and a TDQ (for permanent logging)
  5. Produces a summary showing pass/fail counts and details of failures

Write the COBOL code for the test harness program and define the test case record layout. Include at least 5 test cases for an account inquiry program.


Exercise 33: Event-Driven Notification System

Design and implement a CICS event-driven notification system for a banking application. The system must:

  1. Detect when a withdrawal exceeds $10,000 (regulatory threshold)
  2. Detect when an account balance drops below $100 (overdraft warning)
  3. Detect when three or more failed login attempts occur for the same user within 10 minutes
  4. For each event, write a notification record to an MQ queue for downstream processing
  5. Maintain event counters in a shared TSQ for real-time monitoring
  6. Provide a CICS inquiry transaction to display current event statistics

Write the event detection paragraphs, the MQ message formatting, and the monitoring transaction.


Exercise 34: CICS Performance Monitoring Dashboard

Design a CICS COBOL program that collects and displays performance metrics. The program should:

  1. Use EXEC CICS INQUIRE commands to gather system statistics (task counts, file I/O counts, queue depths)
  2. Store historical metrics in auxiliary TSQs (one item per collection interval, every 5 minutes)
  3. Display a dashboard map showing current metrics, 1-hour averages, and trend indicators (up/down arrows)
  4. Support PF7/PF8 to scroll through historical data
  5. Highlight metrics that exceed configurable thresholds in red (using BMS attribute bytes)

Define the BMS map layout, the metric collection logic, the threshold configuration, and the historical data management approach. Write the key COBOL paragraphs for metric collection and display.