Chapter 25 Quiz: Advanced CICS Programming

Test your understanding of advanced CICS programming concepts. Each question is followed by a hidden answer -- try to answer before revealing it.


Question 1

What is the maximum size of a COMMAREA in CICS, and what modern alternative removes this limitation?

A) 32,000 bytes; Temporary Storage Queues B) 32,763 bytes; Channels and Containers C) 64,000 bytes; Shared Data Tables D) 65,535 bytes; MQ Messages

Show Answer **B) 32,763 bytes; Channels and Containers** The COMMAREA has a maximum size of 32,763 bytes. Channels and containers, introduced in CICS TS V3.1, remove this limitation. Each container within a channel can hold approximately 500 MB of data. Containers also provide named, self-documenting data areas, which is a significant improvement over the flat, unnamed COMMAREA structure.

Question 2

In a pseudo-conversational CICS program, what is the value of EIBCALEN on the very first invocation of a transaction?

Show Answer **Zero (0)**. When a transaction is started for the first time (not as a result of a `RETURN TRANSID` with a COMMAREA), EIBCALEN is zero because no COMMAREA was passed. Programs use this test to detect the first invocation:
IF EIBCALEN = ZERO
    PERFORM 1000-FIRST-TIME
ELSE
    MOVE DFHCOMMAREA TO WS-COMMAREA
    PERFORM 2000-PROCESS-INPUT
END-IF
This is the foundation of pseudo-conversational programming -- the program must determine whether this is a fresh start or a continuation of an ongoing conversation.

Question 3

What is the difference between EXEC CICS LINK and EXEC CICS XCTL?

Show Answer **LINK** creates a new program level, similar to a CALL in batch COBOL. The calling program remains in storage, and control returns to it when the linked program issues `EXEC CICS RETURN`. The calling program can examine the COMMAREA after the LINK completes. **XCTL** (Transfer Control) replaces the current program. The calling program is released from storage, and control does not return to it. When the transferred-to program issues `EXEC CICS RETURN`, control goes to the next higher program level (or back to CICS if there is none). Use LINK for subroutine-style calls where you need the result. Use XCTL for peer-to-peer navigation where the current program's work is complete.

Question 4

Which of the following is NOT a valid advantage of channels and containers over COMMAREA?

A) No practical size limit per container B) Named data areas for self-documentation C) Ability to browse containers in a channel D) Faster data transfer between programs E) Support for binary (BIT) data

Show Answer **D) Faster data transfer between programs** Channels and containers do not inherently provide faster data transfer. In fact, there may be slight additional overhead compared to COMMAREA due to the named lookup mechanism. The advantages are structural: no size limit (A), named containers (B), browsability (C), and native binary data support (E). The performance difference is negligible in practice, but "faster" is not a valid claim.

Question 5

True or False: A Transient Data Queue (TDQ) supports random access by item number, similar to a Temporary Storage Queue (TSQ).

Show Answer **False.** TDQs support only sequential (FIFO) access. Once a record is read from a TDQ, it is removed from the queue (destructive read). TSQs support random access by item number and non-destructive reads -- the same item can be read multiple times. This fundamental difference determines when to use each: - **TSQ**: Multi-page browse data, scratchpad, inter-transaction shared data (rereadable, random access) - **TDQ**: Audit logs, print output, triggered processing (sequential, destructive read, trigger support)

Question 6

What does the SYNCONRETURN option do on an EXEC CICS LINK command with a SYSID parameter?

Show Answer **SYNCONRETURN** causes CICS to take a syncpoint (commit) when the remote program returns control to the calling program. This means that any database updates, file changes, or MQ operations performed by the remote program are committed independently of the calling program's unit of work. Without SYNCONRETURN, the remote program's updates are held in an uncommitted state until the calling program itself takes a syncpoint or terminates. SYNCONRETURN is useful when the remote operation should be committed regardless of what the calling program does next -- for example, an audit logging service that must persist its records even if the calling transaction later rolls back.

Question 7

A CICS program receives DFHRESP(NOTFND) when attempting to READ a VSAM KSDS record. Which of the following could cause this response?

A) The file is disabled B) The specified key does not exist in the file C) The user is not authorized to read the file D) The file is defined but currently closed

Show Answer **B) The specified key does not exist in the file** NOTFND specifically means the record with the given key was not found in the dataset. The other conditions have their own DFHRESP codes: - File disabled: DFHRESP(DISABLED) - Not authorized: DFHRESP(NOTAUTH) - File closed: DFHRESP(NOTOPEN) Accurate interpretation of RESP codes is essential for writing correct error handling logic.

Question 8

What is the purpose of the CICS two-phase commit protocol, and when is it needed?

Show Answer The **two-phase commit protocol** ensures that updates across multiple resource managers (DB2, VSAM, MQ, etc.) are either all committed or all rolled back -- maintaining atomicity. **Phase 1 (Prepare):** CICS asks each resource manager, "Can you commit?" Each resource manager writes its changes to a recovery log and responds yes or no. **Phase 2 (Commit/Rollback):** If all respond yes, CICS tells all to commit. If any responds no, CICS tells all to rollback. Two-phase commit is needed whenever a single CICS task updates more than one type of recoverable resource. For example, if a fund transfer program updates a DB2 account table AND writes a VSAM audit record AND puts an MQ notification message, two-phase commit ensures that either all three operations complete or none of them do. Without it, a failure could leave the database updated but the audit record missing.

Question 9

In a CICS web service program, what HTTP status code should be returned for each of the following scenarios?

a) The account was found and data is returned successfully b) The requested account ID does not exist c) The request JSON is malformed d) An unexpected DB2 error occurred during processing

Show Answer a) **200 (OK)** -- The request was processed successfully and the response contains the requested data. b) **404 (Not Found)** -- The requested resource (account) does not exist. This maps directly to the CICS DFHRESP(NOTFND) condition. c) **400 (Bad Request)** -- The client sent a request that the server cannot process due to malformed syntax. d) **500 (Internal Server Error)** -- An unexpected error occurred on the server side. The client's request was valid, but the server encountered an internal problem. Using correct HTTP status codes is essential for RESTful web services. The CICS program sets these via the STATUSCODE option on `EXEC CICS WEB SEND`.

Question 10

Which CICS utility transaction allows you to execute CICS API commands interactively from a terminal without writing a program?

A) CEDF B) CEMT C) CECI D) CEBR

Show Answer **C) CECI (Command-Level Interpreter)** CECI allows you to type and execute any CICS command interactively. For example:
CECI WRITEQ TS QUEUE('TESTQ') FROM('HELLO WORLD')
CECI LINK PROGRAM('MYPGM') COMMAREA(&AREA)
The other transactions serve different purposes: - **CEDF**: Execution Diagnostic Facility -- intercepts and displays CICS commands during program execution for debugging - **CEMT**: Master Terminal -- manages CICS resources (programs, files, queues, tasks) - **CEBR**: Temporary Storage Browse -- views the contents of TSQs

Question 11

True or False: An intrapartition TDQ can be configured to automatically start a CICS transaction when the number of records in the queue reaches a specified threshold.

Show Answer **True.** This is called **trigger-level processing**. The trigger level and the transaction to start are defined in the DCT (Destination Control Table) resource definition:
DESTID=AUDT
TYPE=INTRA
TRANSID=AUDR
TRIGLEV=100
When 100 records accumulate in the AUDT queue, CICS automatically initiates transaction AUDR. This pattern is commonly used for deferred processing such as audit logging, print spooling, and batch-style processing within CICS. Extrapartition TDQs do not support trigger-level processing.

Question 12

What is the difference between MAIN temporary storage and AUXILIARY temporary storage?

Show Answer **MAIN temporary storage** is stored in CICS main memory (virtual storage). It is faster because no I/O is required, but it is volatile -- the data is lost if CICS is restarted. It is best for small, transient data that does not need to survive a CICS restart. **AUXILIARY temporary storage** is stored on a VSAM dataset (the CICS temporary storage VSAM file, typically DFHTEMP). It is slower because each write and read involves disk I/O, but the data can survive a CICS restart if the TSQ is defined as recoverable. It is appropriate for large result sets or data that must be preserved across restarts. The storage type is specified on the WRITEQ TS command:
EXEC CICS WRITEQ TS QUEUE(name) FROM(data) MAIN     END-EXEC.
EXEC CICS WRITEQ TS QUEUE(name) FROM(data) AUXILIARY END-EXEC.

Question 13

A CICS program uses EXEC CICS HANDLE ABEND LABEL(9500-RECOVERY). After the abend is caught and the recovery paragraph executes, what is the state of CICS resources?

A) All resources are exactly as they were before the abend B) All recoverable resource changes since the last syncpoint have been rolled back C) Only DB2 changes are rolled back; VSAM changes are preserved D) No resources are affected; the program continues as if nothing happened

Show Answer **B) All recoverable resource changes since the last syncpoint have been rolled back** When CICS catches an abend through HANDLE ABEND, it performs an implicit rollback of all recoverable resources (DB2 updates, recoverable VSAM file changes, MQ operations) back to the last syncpoint. The recovery paragraph then executes in a "clean" state, but: - Non-recoverable VSAM files may retain their changes - TSQ and TDQ writes are typically not rolled back (unless defined as recoverable) - WORKING-STORAGE data retains the values it had at the time of the abend The recovery paragraph can continue processing, send a user-friendly error message, or issue its own ABEND to propagate the failure.

Question 14

What RACF resource class controls access to CICS temporary storage queues?

A) TCICSTRN B) FCICSFCT C) SCICSTST D) DCICSDCT

Show Answer **C) SCICSTST** The CICS security resource classes are: - **TCICSTRN**: Transaction security (which users can execute which transactions) - **CCICSCMD**: CICS system command security - **DCICSDCT**: Transient Data Queue security - **FCICSFCT**: File security (VSAM files) - **SCICSTST**: Temporary Storage Queue security - **PCICSPSB**: DL/I PSB security Each class controls access to a different type of CICS resource through RACF profiles.

Question 15

True or False: A DPL (Distributed Program Link) server program can issue EXEC CICS SEND MAP commands to display data on a terminal.

Show Answer **False.** DPL server programs cannot issue terminal-related commands because they are not associated with a terminal. When a program is invoked via DPL (LINK with SYSID), it runs in the remote CICS region without a terminal facility. Any attempt to issue SEND MAP, RECEIVE MAP, or other terminal I/O commands will result in an error. DPL programs must use COMMAREA or channels/containers for all input and output. This constraint is by design -- DPL programs are meant to be stateless service programs that can be called from any front-end (3270 terminals, CTG, web services) without being tied to a specific presentation mechanism.

Question 16

Which statement correctly describes the PUSH HANDLE and POP HANDLE commands?

Show Answer **PUSH HANDLE** saves the current state of all HANDLE commands (HANDLE ABEND, HANDLE AID, HANDLE CONDITION) onto an internal stack. **POP HANDLE** restores the most recently saved state. This stack-based mechanism allows a program to temporarily change its error or key handling for a specific section of code, then restore the original handling afterward:
EXEC CICS PUSH HANDLE END-EXEC.
EXEC CICS HANDLE ABEND LABEL(9600-RETRY) END-EXEC.
PERFORM 5000-RISKY-OPERATION.
EXEC CICS POP HANDLE END-EXEC.
Without PUSH/POP, the HANDLE ABEND for the risky operation would remain in effect for the rest of the program, potentially interfering with other error handling logic. PUSH/POP ensures proper scoping of HANDLE commands.

Question 17

A CICS program needs to pass a 500 KB data structure to a called program. Which approach should be used?

A) COMMAREA on the LINK command B) A Temporary Storage Queue C) A channel with one or more containers on the LINK command D) An Extrapartition Transient Data Queue

Show Answer **C) A channel with one or more containers on the LINK command** The COMMAREA maximum is 32,763 bytes, so option A cannot handle 500 KB. While TSQs (option B) could work, they require the called program to know the queue name and perform separate I/O operations, creating loose coupling. Extrapartition TDQs (option D) are for external file interfaces, not inter-program communication. Channels and containers are the correct solution because: - Each container can hold approximately 500 MB - The channel is automatically associated with the LINK - No separate naming or cleanup is needed - The called program uses `EXEC CICS GET CONTAINER` to retrieve the data - Containers are automatically freed when the channel goes out of scope

Question 18

What is the correct order of steps to expose an existing COBOL CICS program as a JSON REST API using CICS TS V5.2+ automatic transformation?

Show Answer The correct order is: 1. **Define the COBOL data structure** in a copybook that describes the COMMAREA (request and response layouts). 2. **Run the DFHJS2LS utility** to generate a JSON schema and a CICS JSON transformer from the COBOL copybook. This creates the mapping between JSON field names and COBOL data items. 3. **Define a PIPELINE resource** in the CSD that references the JSON transformer. The pipeline handles the automatic JSON-to-COMMAREA and COMMAREA-to-JSON conversion. 4. **Define a URIMAP resource** that maps a URL pattern (e.g., `/api/accounts/{id}`) to the COBOL program, specifying the pipeline. 5. **Install the resources** using CEDA INSTALL. The existing COBOL program requires **zero code changes**. CICS automatically receives the HTTP request, transforms the JSON body to a COMMAREA, LINKs to the program, transforms the COMMAREA response back to JSON, and sends the HTTP response.

Question 19

A CICS application writes audit records using EXEC CICS WRITEQ TD QUEUE('AUDT'). What happens if the AUDT queue is an intrapartition TDQ and the transaction subsequently abends?

A) The audit records are automatically rolled back (removed from the queue) B) The audit records remain in the queue regardless of the abend C) It depends on whether the TDQ is defined as recoverable in the DCT D) The audit records are moved to a dead-letter queue

Show Answer **C) It depends on whether the TDQ is defined as recoverable in the DCT** If the intrapartition TDQ is defined as **recoverable** (RECOVSTATUS=RECOVERABLE), the WRITEQ TD operations participate in the CICS unit of work. When the transaction abends, CICS performs an implicit SYNCPOINT ROLLBACK, which removes the audit records from the queue. If the TDQ is defined as **not recoverable** (the default), the writes are committed immediately and are not affected by a subsequent abend. The audit records remain in the queue. For audit logging, the TDQ should typically be **not recoverable** -- you want to preserve the audit trail even if the transaction fails. For transactional queues (where queue writes should be atomic with other operations), the TDQ should be recoverable.

Question 20

What is the CICS Transaction Gateway (CTG), and what protocol does it use?

Show Answer The **CICS Transaction Gateway (CTG)** is a middleware component that provides a bridge between external applications (Java, .NET, web applications) and CICS transactions. It enables non-mainframe applications to invoke CICS programs as if they were local services. CTG uses the **External Call Interface (ECI)** protocol to communicate with CICS. The flow is: 1. The external application creates a request with a COMMAREA or channel/containers 2. CTG sends the request to CICS via ECI 3. CICS runs the specified program as a DPL (Distributed Program Link) call 4. The program processes the request and returns data in the COMMAREA 5. CTG returns the response to the external application Programs called through CTG must be DPL-capable: no terminal I/O, stateless design, and all communication through the COMMAREA or channels.

Question 21

True or False: When using EXEC CICS SEND MAP with the DATAONLY option, both the static map text and the variable data fields are transmitted to the terminal.

Show Answer **False.** The DATAONLY option sends only the variable data fields (those that have been modified in the symbolic map) to the terminal. The static text (labels, titles, field prompts) that was previously painted on the screen by a MAPONLY or full SEND MAP remains unchanged. The three modes are: - **No option (default)**: Sends both the physical map (static text) and the data fields - **MAPONLY**: Sends only the physical map (static text, field attributes) without data values - **DATAONLY**: Sends only modified data fields without the static text Using DATAONLY is a performance optimization for 3270 communication -- it minimizes the amount of data transmitted over the network when only field values have changed.

Question 22

What command would you use to check if a specific CICS program has been loaded and is available, and to force a fresh copy to be loaded?

Show Answer To **check** the program status:
CEMT INQUIRE PROGRAM(MYPGM)
This displays the program's status including whether it is enabled, the language, the load date/time, and the use count. To **force a fresh copy** (newcopy):
CEMT SET PROGRAM(MYPGM) NEWCOPY
Or equivalently:
CEMT SET PROGRAM(MYPGM) NEW
NEWCOPY tells CICS to discard the currently loaded copy and load a fresh version from the load library the next time the program is invoked. This is essential during development and deployment when a new version of the program has been compiled and link-edited. Without NEWCOPY, CICS continues to use the version that is already in storage. Note: NEWCOPY only works for programs that are not currently in use (use count = 0). If the program is active, you must wait for all tasks using it to complete, or use PHASEIN instead of NEWCOPY (PHASEIN loads the new copy for new tasks while allowing existing tasks to finish with the old copy).

Question 23

What are the key differences between the CEDF and CECI debugging tools?

Show Answer **CEDF (Execution Diagnostic Facility):** - Intercepts CICS API commands during actual program execution - Shows each command before and after execution with parameter values - Displays EIBRESP and EIBRESP2 after each command - Works with running programs -- you start CEDF, then run your transaction - Used for step-through debugging of existing programs - Cannot execute commands independently **CECI (Command-Level Interpreter):** - Executes individual CICS commands typed by the user - Does not require a running program - Used for ad-hoc testing of individual commands - Can test file reads, queue writes, program links, etc. - Results are displayed immediately - Useful for verifying resource definitions and data In practice, CEDF is used for debugging program logic and tracing the flow of CICS commands, while CECI is used for standalone testing of individual commands, verifying that resources are correctly defined, and exploring data in files and queues.

Question 24

A CICS program needs to communicate with an external system by putting a message on an MQ queue. The MQ PUT must be committed only if the DB2 update in the same transaction succeeds. How is this achieved?

Show Answer This is achieved through **CICS syncpoint coordination**. Both DB2 and MQ participate in the CICS two-phase commit protocol. The MQ PUT operation is held in an uncommitted state until the program issues a syncpoint or returns.
      * Update DB2
           EXEC SQL UPDATE ACCOUNTS
               SET BALANCE = BALANCE - :WS-AMOUNT
               WHERE ACCT_ID = :WS-ACCT-ID
           END-EXEC.

      * Put MQ message
           EXEC CICS MQ PUT
               QUEUEHANDLE(WS-Q-HANDLE)
               FROM(WS-MQ-MSG)
               DATALENGTH(WS-MSG-LEN)
               RESP(WS-RESP)
           END-EXEC.

      * Both are committed together
           EXEC CICS SYNCPOINT END-EXEC.
If either operation fails and the program issues `SYNCPOINT ROLLBACK`, both the DB2 update and the MQ PUT are rolled back. The MQ message does not become visible to other applications until the syncpoint commits. This ensures transactional consistency across DB2 and MQ.

Question 25

True or False: The CURSOR option on EXEC CICS SEND MAP positions the cursor at a specific field by specifying the field name from the symbolic map.

Show Answer **False.** The CURSOR option on SEND MAP takes a numeric value representing the absolute screen position (0-based offset from position 0,0). The position is calculated as `(row - 1) * screen_width + (column - 1)`. For a standard 24x80 screen:
COMPUTE WS-CURSOR-POS = (WS-ERROR-ROW - 1) * 80
    + (WS-ERROR-COL - 1).
EXEC CICS SEND MAP('MYMAP')
    MAPSET('MYSET')
    FROM(MY-MAPO)
    CURSOR(WS-CURSOR-POS)
END-EXEC.
Alternatively, you can move -1 to the field's length attribute (the `L` suffixed field in the symbolic map) and use `CURSOR` without a position value -- CICS will position the cursor at the first field with a length of -1:
MOVE -1 TO ACCT-NUML.
EXEC CICS SEND MAP('MYMAP') ... CURSOR END-EXEC.
This second approach is more commonly used because it does not require calculating absolute positions.

Question 26

What is the CICS Liberty JVM server, and how does it enable modernization of COBOL applications?

Show Answer The **CICS Liberty JVM server** is an embedded Java application server (based on IBM WebSphere Liberty) that runs within a CICS region. Introduced in CICS TS V5.1, it allows Java EE applications to run alongside COBOL programs in the same CICS environment. It enables modernization in several ways: 1. **RESTful APIs**: Java JAX-RS applications can expose REST endpoints that call COBOL programs via the JCICS API (`Program.link()`), providing modern web interfaces to legacy logic. 2. **Web applications**: Java servlets and JSPs can provide browser-based front-ends that replace 3270 terminal interfaces while reusing the same COBOL back-end programs. 3. **Mixed workloads**: Java and COBOL programs can participate in the same CICS unit of work, sharing transactional context and resource management. 4. **Incremental migration**: New features can be written in Java while existing COBOL business logic is preserved, avoiding risky wholesale rewrites. The architecture allows a modern Java front-end to call existing COBOL programs via LINK, with CICS managing the thread safety, security, and transactional integrity across both languages.

Question 27

A banking application uses STRING 'BROWSE' EIBTRMID DELIMITED BY SIZE INTO WS-TSQ-NAME to create unique TSQ names. Why is this approach important, and what could go wrong if all terminals used the same TSQ name?

Show Answer Including the terminal ID (EIBTRMID) in the TSQ name creates a **unique queue per terminal session**. This is critical because: 1. **Data isolation**: Each user's browse results are in a separate queue. Without unique names, User A's account transaction history could be mixed with User B's, creating both confusion and a serious security breach. 2. **Concurrency**: If multiple users run the same transaction simultaneously, their TSQ writes and reads would interfere with each other. User A might page forward and see User B's records. 3. **Cleanup**: When a user ends their session, only their queue is deleted, without affecting other users. Potential issues with a shared TSQ name: - **Data leakage**: One user could see another user's sensitive financial data - **Item number conflicts**: Page calculations would be wrong because the item count reflects records from all users - **Unexpected deletions**: One user's cleanup could delete another user's active browse data - **Regulatory violations**: Exposing customer data across sessions violates privacy regulations For non-terminal tasks (such as those started by triggers or CTG), use the user ID or a unique task identifier instead of EIBTRMID.

Question 28

What is the correct way to handle the situation where a CICS program attempts to WRITE a record to a VSAM KSDS and receives DFHRESP(NOSPACE)?

Show Answer DFHRESP(NOSPACE) indicates that the VSAM dataset has exhausted all its allocated space (primary and all secondary extents). The correct handling involves: 1. **Immediate response**: Do not retry the write -- it will fail again with the same error until space is freed.
EXEC CICS WRITE FILE('ACCTFILE')
    FROM(WS-RECORD)
    RIDFLD(WS-KEY)
    LENGTH(WS-REC-LEN)
    RESP(WS-RESP)
END-EXEC.

IF WS-RESP = DFHRESP(NOSPACE)
    MOVE 'File full - contact operations'
        TO WS-ERROR-MSG
    PERFORM 9000-WRITE-AUDIT-LOG
    PERFORM 8000-NOTIFY-USER
    EXEC CICS SYNCPOINT ROLLBACK END-EXEC
END-IF
2. **Audit logging**: Write the error to a TDQ or CICS journal so operations can be alerted. 3. **User notification**: Send a meaningful error message to the user rather than allowing an abend. 4. **Rollback**: Issue SYNCPOINT ROLLBACK to undo any partial transaction changes. 5. **Operations response**: The operations team needs to either extend the dataset (if possible), reorganize it to reclaim deleted space, or allocate it to a larger volume. This is typically done by closing the file in CICS, running an IDCAMS ALTER to increase space, and reopening.

Question 29

Analyze the following code. What problem will occur, and how should it be fixed?

           EXEC CICS READ FILE('ACCTFILE')
               INTO(WS-ACCT-REC)
               RIDFLD(WS-ACCT-KEY)
               LENGTH(WS-REC-LEN)
               UPDATE
               RESP(WS-RESP)
           END-EXEC.

           IF WS-RESP = DFHRESP(NORMAL)
               ADD WS-DEPOSIT TO ACCT-BALANCE
               PERFORM 5000-VALIDATE-BALANCE
               IF WS-BALANCE-VALID = 'Y'
                   EXEC CICS REWRITE FILE('ACCTFILE')
                       FROM(WS-ACCT-REC)
                       LENGTH(WS-REC-LEN)
                       RESP(WS-RESP)
                   END-EXEC
               END-IF
           END-IF.
Show Answer **Problem:** When the READ with UPDATE succeeds but `WS-BALANCE-VALID` is 'N', the program skips the REWRITE but **never releases the UPDATE lock**. The record remains locked in the VSAM file, blocking all other transactions that attempt to READ UPDATE or REWRITE that record. This causes a resource deadlock that can hang other users until the CICS task times out or is purged. **Fix:** Add an explicit UNLOCK command (or a REWRITE of the original record) when the validation fails:
           IF WS-RESP = DFHRESP(NORMAL)
               ADD WS-DEPOSIT TO ACCT-BALANCE
               PERFORM 5000-VALIDATE-BALANCE
               IF WS-BALANCE-VALID = 'Y'
                   EXEC CICS REWRITE FILE('ACCTFILE')
                       FROM(WS-ACCT-REC)
                       LENGTH(WS-REC-LEN)
                       RESP(WS-RESP)
                   END-EXEC
               ELSE
                   EXEC CICS UNLOCK FILE('ACCTFILE')
                       RESP(WS-RESP)
                   END-EXEC
               END-IF
           END-IF
Always ensure that every READ UPDATE path either ends with a REWRITE (to apply changes and release the lock) or an UNLOCK (to release the lock without changes). This is one of the most common bugs in CICS VSAM programming.

Question 30

What are the three types of DB2 threads that CICS can use, and when is each appropriate?

Show Answer The three types of DB2 threads in CICS are: 1. **Pool threads**: Shared threads from a common pool defined by the DB2CONN THREADLIMIT parameter. A pool thread is allocated when a transaction executes its first SQL statement and returned to the pool after each SQL call (or at syncpoint, depending on configuration). Pool threads are appropriate for **low-frequency transactions** that execute SQL infrequently -- the sharing model keeps resource usage low. 2. **Entry threads**: Dedicated threads defined by DB2ENTRY resource definitions. Each DB2ENTRY associates a specific transaction (or group of transactions) with a dedicated thread. Entry threads provide better performance because the thread is pre-allocated and reused without the overhead of pool thread allocation. They are appropriate for **high-frequency, performance-critical transactions** such as ATM inquiries or teller operations. 3. **Command threads**: Used internally by CICS for DB2 administrative commands (such as those issued through the DSNC transaction). Command threads are not used by application programs. The choice between pool and entry threads is a capacity planning decision. Pool threads are flexible but have higher per-SQL overhead. Entry threads are faster but consume dedicated resources even when the transaction is not running.