Chapter 24 Quiz: CICS Transaction Processing Fundamentals

Test your understanding of CICS architecture, pseudo-conversational programming, BMS maps, COMMAREA, SEND/RECEIVE MAP, HANDLE CONDITION, and RESP-based error handling. Each question is followed by a hidden answer -- try to answer before revealing it.


Question 1

What is the fundamental difference between conversational and pseudo-conversational programming in CICS?

Show Answer In **conversational** programming, the CICS task remains active while the user is thinking and typing. The program issues a SEND MAP to display data, then a RECEIVE MAP to wait for user input. The task (and all its resources -- storage, file locks, enqueue entries) is held for the entire duration of the user's think time, which may be 10 to 60 seconds. In **pseudo-conversational** programming, the CICS task terminates after sending the map. The program issues SEND MAP followed by `RETURN TRANSID('xxxx') COMMAREA(data)`, which ends the task and frees all resources. When the user presses Enter or a PF key, CICS starts a **new task** that runs the same (or a different) program. The COMMAREA carries state information between invocations, creating the illusion of a continuous conversation. Pseudo-conversational is the standard approach for production CICS systems because it can support thousands of concurrent users without exhausting task resources. Conversational programming is rarely used except for quick-running internal tasks.

Question 2

What does EIBCALEN contain, and how is it used to detect the first invocation of a pseudo-conversational program?

Show Answer **EIBCALEN** (Execute Interface Block -- COMMAREA Length) contains the length of the COMMAREA passed to the current program. It is a halfword binary field (PIC S9(04) COMP). On the **first invocation** of a pseudo-conversational transaction -- when the user types the transaction ID and presses Enter -- there is no COMMAREA because no prior program invocation passed one. Therefore, **EIBCALEN = 0**. On **subsequent invocations**, the COMMAREA passed in the previous `RETURN TRANSID(...) COMMAREA(...)` is available, and EIBCALEN reflects its length. The standard pattern is:
       IF EIBCALEN = 0
           PERFORM 1000-FIRST-TIME
       ELSE
           MOVE DFHCOMMAREA TO WS-COMM-AREA
           PERFORM 2000-PROCESS-INPUT
       END-IF
It is critical to check EIBCALEN before referencing DFHCOMMAREA, because accessing DFHCOMMAREA when EIBCALEN = 0 causes an ASRA (data exception) or AEYC abend.

Question 3

A BMS map field is defined with ATTRB=(UNPROT,BRT,IC). What do each of these attribute characters mean?

Show Answer - **UNPROT** (Unprotected): The user can type data into this field. The field accepts keyboard input. In contrast, PROT or ASKIP would prevent the user from entering data. - **BRT** (Bright): The field is displayed with high intensity (bright). The three intensity levels are DRK (dark/invisible -- useful for passwords), NORM (normal intensity), and BRT (bright/highlighted intensity). - **IC** (Initial Cursor): The cursor is positioned at this field when the map is sent to the terminal. Only one field per map should have the IC attribute. If multiple fields have IC, the cursor goes to the last one in the map definition. The attribute byte is a single byte that CICS places immediately before the field data on the screen. In the COBOL program, the attribute byte can be modified at runtime by moving a value from the DFHBMSCA copybook to the field's attribute variable (e.g., `MOVE DFHBMPRF TO ACCTIDA` to make it protected).

Question 4

What is the purpose of DFHCOMMAREA in the LINKAGE SECTION of a CICS COBOL program?

Show Answer **DFHCOMMAREA** is a special data name in the LINKAGE SECTION that CICS uses to address the communication area (COMMAREA) passed by the invoking mechanism. It provides the program with access to the data that was passed via: - `RETURN TRANSID('xxxx') COMMAREA(data)` from a previous pseudo-conversational iteration - `LINK PROGRAM('pgm') COMMAREA(data)` from a calling program - `XCTL PROGRAM('pgm') COMMAREA(data)` from a transferring program The standard practice is to define DFHCOMMAREA with a minimal layout in the LINKAGE SECTION and immediately copy it to a WORKING-STORAGE area for processing:
       LINKAGE SECTION.
       01  DFHCOMMAREA              PIC X(500).

       PROCEDURE DIVISION.
           IF EIBCALEN > 0
               MOVE DFHCOMMAREA TO WS-COMM-AREA
           END-IF
This copy-to-WORKING-STORAGE pattern is important because the COMMAREA memory may be in a different location on each invocation, and modifying DFHCOMMAREA directly can cause issues if the length changes between invocations.

Question 5

What is the difference between LINK and XCTL in CICS program control?

A) LINK returns control to the caller; XCTL does not B) LINK passes a COMMAREA; XCTL does not C) LINK starts a new task; XCTL reuses the current task D) LINK is for batch programs; XCTL is for online programs

Show Answer **A) LINK returns control to the caller; XCTL does not.** **LINK** is analogous to a COBOL CALL statement. It transfers control to another program and, when that program issues RETURN (without TRANSID), control returns to the statement after the LINK in the calling program. The calling program's storage is preserved. **XCTL** (Transfer Control) is analogous to a GO TO another program. It transfers control to the target program but **does not return** to the invoking program. The invoking program's storage is released. XCTL is efficient for menu-driven navigation where the menu program does not need to regain control after the selected function completes. Both LINK and XCTL can pass a COMMAREA (option B is incorrect). Both operate within the same CICS task (option C is incorrect). Both are for online CICS programs (option D is incorrect).

Question 6

In a BMS map, what is the difference between the physical map and the symbolic map?

Show Answer The **physical map** is a load module that CICS uses at runtime to control the screen formatting. It contains the screen layout information: field positions, lengths, attributes, colors, and initial values. The physical map is generated by assembling the BMS macros with `TYPE=MAP` and is loaded into CICS when the program issues SEND MAP or RECEIVE MAP. The **symbolic map** is a COBOL copybook that provides the data names the COBOL program uses to set output field values and read input field values. It is generated by assembling the BMS macros with `TYPE=DSECT`. The symbolic map contains: - An **input structure** with fields like `ACCTIDI` (the data the user typed) - An **output structure** with fields like `ACCTIDO` (the data the program sends) - **Attribute fields** like `ACCTIDA` (to modify field attributes at runtime) - **Length fields** like `ACCTIDL` (the length of data the user entered) The physical map and symbolic map must always be generated from the same BMS macros and kept in sync. If they diverge, fields will appear in wrong positions or with wrong formats.

Question 7

What does the MAPFAIL condition indicate when it occurs on a RECEIVE MAP command?

Show Answer **MAPFAIL** (EIBRESP = 81) indicates that the terminal user pressed an AID key (Enter, PF key, PA key, Clear) **without modifying any data fields** on the screen. No modified data tag (MDT) was set for any field, so there is no data for CICS to map into the symbolic map structure. MAPFAIL does NOT mean the user pressed Enter with an empty screen -- it means no field was modified. A field that already contained data but was not changed will not trigger the MDT. The appropriate handling depends on the application:
       EXEC CICS RECEIVE MAP('ACCTMAP')
                         MAPSET('ACCTMS')
                         INTO(ACCT-MAP-I)
                         RESP(WS-RESP)
       END-EXEC
       IF WS-RESP = DFHRESP(MAPFAIL)
           MOVE 'Please enter data and press Enter'
             TO ERRMSGO
           PERFORM 9100-RESEND-MAP
       END-IF
Note that MAPFAIL can also occur if the user presses the CLEAR key, which erases the screen. In that case, the program should typically resend the entire map with ERASE.

Question 8

True or False: When a CICS program issues RETURN TRANSID('AINQ') COMMAREA(WS-CA) LENGTH(200), the current task continues to run until the user presses a key.

Show Answer **False.** The RETURN with TRANSID **immediately terminates** the current task. The task's resources (storage, enqueues, file positions) are released. CICS retains only the COMMAREA data and the association between the terminal and the transaction ID 'AINQ'. When the user later presses Enter or a PF key, CICS creates a **new task** and attaches the specified transaction ID 'AINQ' to it. The new task's program receives the COMMAREA through DFHCOMMAREA with EIBCALEN set to 200. This immediate task termination is the core of pseudo-conversational programming and is what makes it so resource-efficient. During the 10-30 seconds of user think time, no CICS task exists for that terminal -- the resources are available for other users' transactions.

Question 9

What is the purpose of the RESP option on EXEC CICS commands, and what are the valid values it can contain?

Show Answer The **RESP** option provides inline error handling for CICS commands. When specified, CICS places a numeric response code in the specified variable instead of raising an exceptional condition. This allows the program to check for errors with an EVALUATE or IF statement immediately after the command, rather than relying on HANDLE CONDITION to transfer control to a paragraph.
       EXEC CICS READ FILE('ACCTFIL')
                      INTO(WS-ACCT-RECORD)
                      RIDFLD(WS-ACCT-KEY)
                      RESP(WS-RESP)
                      RESP2(WS-RESP2)
       END-EXEC
       EVALUATE WS-RESP
           WHEN DFHRESP(NORMAL)    ...
           WHEN DFHRESP(NOTFND)    ...
           WHEN DFHRESP(IOERR)     ...
       END-EVALUATE
Common RESP values (checked via DFHRESP copybook names): - DFHRESP(NORMAL) = 0 -- Success - DFHRESP(NOTFND) = 13 -- Record not found - DFHRESP(DUPREC) = 14 -- Duplicate record - DFHRESP(DUPKEY) = 15 -- Duplicate alternate key - DFHRESP(INVREQ) = 16 -- Invalid request - DFHRESP(IOERR) = 17 -- I/O error - DFHRESP(NOSPACE) = 18 -- No space for write - DFHRESP(LENGERR) = 22 -- Length error - DFHRESP(MAPFAIL) = 36 -- No modified data on receive - DFHRESP(PGMIDERR) = 27 -- Program not found - DFHRESP(DISABLED) = 84 -- Resource disabled The RESP approach is preferred over HANDLE CONDITION because it provides structured, in-line error handling without GO TO-like control flow.

Question 10

A CICS COBOL program needs to read a VSAM KSDS record, modify it, and write the changes back. Which sequence of EXEC CICS commands is correct?

A) READ, WRITE B) READ with UPDATE, REWRITE C) READ, DELETE, WRITE D) STARTBR, READNEXT, REWRITE

Show Answer **B) READ with UPDATE, REWRITE** The correct sequence for modifying an existing VSAM KSDS record in CICS is: 1. `EXEC CICS READ FILE('name') INTO(area) RIDFLD(key) UPDATE` -- This reads the record and acquires an **exclusive lock** on it, preventing other tasks from modifying it simultaneously. 2. Modify the data in the INTO area. 3. `EXEC CICS REWRITE FILE('name') FROM(area)` -- This writes the modified record back to the file and releases the lock. Option A (READ, WRITE) would attempt to add a new record, which would fail with DUPREC because the key already exists. Option C (READ, DELETE, WRITE) would work but is inefficient and not atomic -- another task could intervene between the DELETE and WRITE. Option D (STARTBR, READNEXT, REWRITE) is invalid because REWRITE requires a prior READ with UPDATE, not a browse operation. The UPDATE option on the READ is critical -- without it, no lock is acquired, and the REWRITE will fail with INVREQ.

Question 11

What happens if a CICS pseudo-conversational program issues RETURN without the TRANSID option?

Show Answer When a CICS program issues `EXEC CICS RETURN END-EXEC` without the TRANSID option, the current task terminates and **no transaction is associated with the terminal** for the next user input. The terminal returns to the state where the user must type a new transaction ID to start a new transaction. This is the correct way to **exit** a pseudo-conversational application. The user sees the terminal return to the "blank screen" or CICS good morning message, ready for a new transaction. In contrast, `RETURN TRANSID('AINQ') COMMAREA(data)` associates the transaction AINQ with the terminal, so the next Enter key press will start that transaction automatically. Without the TRANSID, the user must explicitly type a transaction ID. A common pattern for exit:
       IF USER-PRESSED-PF3
           EXEC CICS SEND TEXT
                     FROM(WS-GOODBYE-MSG)
                     LENGTH(WS-MSG-LEN)
                     ERASE
                     FREEKB
           END-EXEC
           EXEC CICS RETURN END-EXEC
       END-IF

Question 12

What is the purpose of the ERASE option on a SEND MAP command?

Show Answer The **ERASE** option on SEND MAP causes CICS to erase the entire screen before writing the map data. Without ERASE, the map data is overlaid on whatever is currently displayed, which can leave residual data from previous screens visible in areas not covered by the new map.
       EXEC CICS SEND MAP('ACCTMAP')
                      MAPSET('ACCTMS')
                      FROM(ACCT-MAP-O)
                      ERASE
       END-EXEC
ERASE should be used when: - Switching to a completely different screen layout - The first time a screen is displayed in a transaction - After the user presses CLEAR (which erases the screen locally but not the CICS-maintained image) ERASE should NOT be used when: - Updating only specific fields on an existing screen (use DATAONLY instead) - Refreshing the data area while keeping the screen layout (field labels, headers) The complementary option **ERASEAUP** (Erase All Unprotected) clears only the input fields while keeping the protected fields (labels, headers) intact -- useful for resetting a form for new input.

Question 13

What is the difference between SEND MAP MAPONLY and SEND MAP DATAONLY?

Show Answer **MAPONLY** sends only the constant portions of the map -- field labels, titles, attribute bytes, and INITIAL values defined in the BMS macros. It does NOT send any data from the program's symbolic map output area. This is used when you want to display the screen layout with its default values but no application data. **DATAONLY** sends only the variable data from the program's symbolic map output area -- the values the program has moved to the output fields (like ACCTIDO, ACNMEO, ACBALO). It does NOT resend the constant portions. This is used to update the data fields on a screen that is already displayed, without the overhead of resending the entire screen layout. Typical usage pattern:
      * First display: send both constants and data
       EXEC CICS SEND MAP('ACCTMAP')
                      MAPSET('ACCTMS')
                      FROM(ACCT-MAP-O)
                      ERASE
       END-EXEC

      * Subsequent refresh: send only updated data
       EXEC CICS SEND MAP('ACCTMAP')
                      MAPSET('ACCTMS')
                      FROM(ACCT-MAP-O)
                      DATAONLY
       END-EXEC
Sending both constants and data (no MAPONLY or DATAONLY) is the default and is called **MAPATTS** -- it sends everything.

Question 14

What is the purpose of the TIOAPFX=YES parameter in a BMS map definition?

Show Answer **TIOAPFX=YES** causes the BMS macro to generate a 12-byte **filler** at the beginning of the symbolic map copybook. This filler reserves space for the Terminal I/O Area Prefix (TIOAPFX), which CICS uses internally for terminal control information. Without TIOAPFX=YES, the programmer would need to account for this prefix manually, which is error-prone. With TIOAPFX=YES, the generated COBOL copybook automatically includes:
       01  ACCTMAPI.
           02  FILLER                PIC X(12).
           02  ACCTIDL               PIC S9(04) COMP.
           02  ACCTIDA               PIC X(01).
           ...
TIOAPFX=YES has been the standard since CICS TS 1.3 and should always be specified. Older programs that use TIOAPFX=NO require the programmer to define the prefix area themselves or use SET ADDRESS to bypass it, which is fragile and no longer recommended.

Question 15

A programmer writes the following code to handle a file read error, but it does not work correctly. What is the problem?

       EXEC CICS HANDLE CONDITION
                 NOTFND(8100-NOT-FOUND)
       END-EXEC

       EXEC CICS READ FILE('ACCTFIL')
                      INTO(WS-ACCT-RECORD)
                      RIDFLD(WS-ACCT-KEY)
                      RESP(WS-RESP)
       END-EXEC

       IF WS-RESP = DFHRESP(NOTFND)
           MOVE 'Account not found' TO WS-MSG
       END-IF
Show Answer The problem is that **RESP** and **HANDLE CONDITION** are mutually exclusive**. When the RESP option is specified on a CICS command, it **overrides** any active HANDLE CONDITION for that command. CICS will place the response code in WS-RESP but will **never** branch to 8100-NOT-FOUND. Conversely, if RESP were not specified, the HANDLE CONDITION would transfer control to 8100-NOT-FOUND on NOTFND, and the IF test after the READ would never execute (because control would have branched away). The fix is to use **one approach or the other**, not both: **RESP approach (preferred):**
       EXEC CICS READ FILE('ACCTFIL')
                      INTO(WS-ACCT-RECORD)
                      RIDFLD(WS-ACCT-KEY)
                      RESP(WS-RESP)
       END-EXEC
       IF WS-RESP = DFHRESP(NOTFND)
           MOVE 'Account not found' TO WS-MSG
       END-IF
**HANDLE CONDITION approach (legacy):**
       EXEC CICS HANDLE CONDITION
                 NOTFND(8100-NOT-FOUND)
       END-EXEC
       EXEC CICS READ FILE('ACCTFIL')
                      INTO(WS-ACCT-RECORD)
                      RIDFLD(WS-ACCT-KEY)
       END-EXEC
      * Only reached if READ succeeded

Question 16

How does CICS implement pseudo-conversational transaction chaining when different programs handle different screens in a workflow?

Show Answer CICS uses the **RETURN TRANSID** mechanism to chain different transactions together. Each screen in the workflow can be handled by a different transaction ID and program, with the COMMAREA carrying the workflow state. For example, a banking workflow might chain: 1. Program CUSTMENU (Trans ID: CMNU) sends the menu, then: ```cobol EXEC CICS RETURN TRANSID('CINQ') COMMAREA(WS-CA) END-EXEC ``` This means the next Enter key press will start transaction CINQ. 2. Program CUSTINQ (Trans ID: CINQ) displays customer details, then: ```cobol EXEC CICS RETURN TRANSID('CUPD') COMMAREA(WS-CA) END-EXEC ``` 3. Program CUSTUPD (Trans ID: CUPD) handles the update and chains back to CMNU. Alternatively, a single transaction ID can route to a single program that uses COMMAREA state to determine which screen to display. This single-program approach is simpler but results in a larger program. The multi-program approach is more modular but requires careful COMMAREA design to ensure all programs use the same layout.

Question 17

What CICS abend code would result from the following programming error, and why?

       PROCEDURE DIVISION.
       0000-MAIN.
           MOVE DFHCOMMAREA TO WS-COMM-AREA
           ...
Show Answer This would cause an **ASRA** abend (program check -- typically a 0C4 protection exception or 0C7 data exception) on the **first invocation** of the pseudo-conversational transaction. On the first invocation, EIBCALEN = 0, meaning there is no COMMAREA. The DFHCOMMAREA pointer references either uninitialized storage or an invalid address. Attempting to MOVE DFHCOMMAREA when no COMMAREA exists accesses invalid memory, causing a program check. The fix is to always check EIBCALEN before accessing DFHCOMMAREA:
       PROCEDURE DIVISION.
       0000-MAIN.
           IF EIBCALEN > 0
               MOVE DFHCOMMAREA TO WS-COMM-AREA
           ELSE
               INITIALIZE WS-COMM-AREA
           END-IF
This is one of the most common CICS programming errors and is often the first bug encountered by programmers new to CICS.

Question 18

What is the difference between a Transient Data (TD) queue and a Temporary Storage (TS) queue in CICS?

Show Answer **Transient Data (TD) queues** are sequential, one-directional queues. Records are read destructively -- once a record is read (READQ TD), it is removed from the queue. TD queues can be: - **Intrapartition**: Reside on a CICS-managed dataset and can trigger a transaction automatically when the queue depth reaches a threshold (trigger level). - **Extrapartition**: Map to a physical sequential dataset (QSAM) for interfacing with batch jobs or other systems. TD queues are ideal for audit logging, print output, and event-driven processing. **Temporary Storage (TS) queues** are random-access, non-destructive queues. Records can be read by item number without being removed. TS queues are: - Created dynamically when the first record is written - Accessible from any task using the queue name - Stored in MAIN (memory) or AUXILIARY (DASD) storage TS queues are ideal for holding intermediate data between pseudo-conversational iterations (e.g., search results, scrollable lists) and for scratch-pad data that multiple tasks need to share. Key differences: | Feature | TD Queue | TS Queue | |---------|----------|----------| | Read behavior | Destructive | Non-destructive | | Access | Sequential | By item number | | Triggering | Yes (intrapartition) | No | | Definition | Must be predefined in DCT | Dynamic | | Typical use | Logging, printing | Scratchpad, browsing |

Question 19

True or False: The COMMAREA maximum size in CICS is 32,763 bytes, and there is no alternative for passing larger data structures between programs.

Show Answer **The first part is approximately correct but the second part is False.** The traditional COMMAREA is limited to **32,763 bytes** (32 KB minus a small overhead). This limit applies to both LINK/XCTL COMMAREA and RETURN TRANSID COMMAREA. However, CICS TS V3 and later provide **Channels and Containers** as an alternative. A Channel is a named collection of Containers, and each Container can hold up to **2 GB** of data. Programs pass the Channel name instead of a COMMAREA:
       EXEC CICS PUT CONTAINER('ACCT-DATA')
                     FROM(WS-LARGE-RECORD)
                     FLENGTH(WS-LARGE-LEN)
                     CHANNEL('ACCT-CHAN')
       END-EXEC

       EXEC CICS LINK PROGRAM('ACCTPROC')
                      CHANNEL('ACCT-CHAN')
       END-EXEC
Channels and Containers solve the 32 KB limitation and also allow passing multiple independent data items (each in its own Container) without packing them into a single COMMAREA structure.

Question 20

What does the FREEKB option do on a SEND MAP command, and when would you use FRSET instead?

Show Answer **FREEKB** (Free Keyboard) unlocks the keyboard after the map is sent. By default, the keyboard is locked after a SEND MAP -- the user cannot type until the keyboard is explicitly freed. Without FREEKB, the user would see the screen but would be unable to type into input fields. **FRSET** (Flag Reset) resets the **Modified Data Tags (MDTs)** for all fields on the screen to their unmodified state. The MDT is a bit in each field's attribute byte that indicates whether the user has typed into the field since it was last sent. When FRSET is specified, all MDTs are turned off. FRSET is important when the program re-displays a screen with previous data. Without FRSET, fields that the user modified on the previous screen iteration would still have their MDTs set, and a RECEIVE MAP would pick up those fields even if the user did not retype in them on the current iteration. With FRSET, only fields that the user actually types into on the current screen display will have MDTs set and will be returned on the next RECEIVE MAP. Common practice is to specify both:
       EXEC CICS SEND MAP('ACCTMAP')
                      MAPSET('ACCTMS')
                      FROM(ACCT-MAP-O)
                      ERASE
                      FREEKB
                      FRSET
       END-EXEC

Question 21

A CICS program needs to determine which key the user pressed (Enter, PF3, PF12, Clear). Which EIB field is checked, and what copybook provides the constant values for comparison?

Show Answer The **EIBAID** field in the Execute Interface Block contains a one-byte code identifying which Attention Identifier (AID) key the user pressed. The **DFHAID** copybook provides named constants for each key.
       COPY DFHAID.

       EVALUATE EIBAID
           WHEN DFHENTER
               PERFORM 2000-PROCESS-INPUT
           WHEN DFHPF3
               PERFORM 8000-EXIT-PROGRAM
           WHEN DFHPF12
               PERFORM 7000-CANCEL-OPERATION
           WHEN DFHCLEAR
               PERFORM 1000-RESEND-SCREEN
           WHEN DFHPA1
               CONTINUE
           WHEN DFHPA2
               CONTINUE
           WHEN OTHER
               MOVE 'Invalid key pressed'
                 TO ERRMSGO
               PERFORM 9100-RESEND-MAP
       END-EVALUATE
The DFHAID copybook defines constants such as: - DFHENTER (X'7D') -- Enter key - DFHPF1 through DFHPF24 -- PF keys - DFHPA1, DFHPA2, DFHPA3 -- PA keys - DFHCLEAR (X'6D') -- Clear key Note that **PA keys** (Program Attention keys) do not transmit screen data -- they only send the AID byte. PF keys and Enter transmit both the AID byte and any modified data fields.

Question 22

Explain the concept of task isolation in CICS and why a COBOL program must not use STOP RUN in a CICS environment.

Show Answer **Task isolation** means that each CICS task runs independently within the shared CICS region. Unlike batch programs that have their own address space, CICS programs share a single address space with hundreds or thousands of other tasks. Each task has its own program storage (WORKING-STORAGE is allocated per task via GETMAIN), but all tasks share the CICS system resources, load modules, and VSAM file control blocks. A COBOL program must **never** use **STOP RUN** in a CICS environment because STOP RUN terminates the **entire run unit** -- which in CICS means the **entire CICS region**, not just the current task. This would abort all active transactions for all users. Instead, CICS programs must use: - `EXEC CICS RETURN END-EXEC` to end the current task normally - `EXEC CICS RETURN TRANSID(...) COMMAREA(...)` for pseudo-conversational return - `GOBACK` from a LINKed program to return to the caller - `EXEC CICS ABEND` for controlled abnormal termination of just the current task Similarly, COBOL file I/O verbs (OPEN, READ, WRITE, CLOSE) must not be used -- CICS manages all file access through EXEC CICS commands. Using native COBOL I/O bypasses CICS resource management and can cause region-wide failures.

Question 23

What is the role of the PCT (Program Control Table) and PPT (Processing Program Table) in CICS, and how do they relate to a COBOL program?

Show Answer The **PCT (Program Control Table)** maps **transaction IDs** to **program names**. When a user types a 4-character transaction ID and presses Enter, CICS looks up the transaction ID in the PCT to determine which program to execute. The PCT entry also specifies security attributes, task priority, and the TWA (Transaction Work Area) size. The **PPT (Processing Program Table)** maps **program names** to their **load modules**. It tells CICS where to find the program (which load library), its language (COBOL, Assembler, C, PL/I), and its attributes (resident, reusable, threadsafe). When CICS needs to execute a program (whether from a PCT transaction or from a LINK/XCTL command), it looks up the program in the PPT. For a COBOL CICS program: 1. The programmer writes the COBOL source and compiles/links it into a load module 2. A CICS system programmer defines the program in the PPT (or uses CSD DEFINE PROGRAM) 3. A CICS system programmer defines the transaction ID in the PCT (or uses CSD DEFINE TRANSACTION) pointing to the program 4. Users type the transaction ID, CICS uses the PCT to find the program name, then the PPT to find and load the program In modern CICS, the CSD (CICS System Definition) file and RDO (Resource Definition Online) replace the macro-based PCT and PPT, but the concepts remain the same.

Question 24

What is a BMS mapset, and why does a single mapset often contain multiple maps?

Show Answer A **BMS mapset** is a named collection of one or more BMS maps that are assembled together into a single physical map load module and a single symbolic map copybook. The mapset is defined with the DFHMSD macro, and individual maps within it are defined with DFHMDI macros.
ACCTMS   DFHMSD TYPE=&SYSPARM,MODE=INOUT,LANG=COBOL,...
*
MENUMAP  DFHMDI SIZE=(24,80),...
         (menu screen fields)
*
DETLMAP  DFHMDI SIZE=(24,80),...
         (detail screen fields)
*
CONFMAP  DFHMDI SIZE=(24,80),...
         (confirmation screen fields)
*
         DFHMSD TYPE=FINAL
A single mapset contains multiple maps when those maps are used by the **same program or transaction** and represent different screens in a workflow. This grouping has practical advantages: 1. **Single COPY statement**: The COBOL program copies one mapset copybook and gets the symbolic definitions for all screens. 2. **Single load module**: CICS loads one mapset module that contains all the screen layouts. 3. **Consistent naming**: The MAPSET parameter in SEND MAP/RECEIVE MAP always refers to the same mapset name. The SEND MAP command specifies both the individual map name and the mapset:
       EXEC CICS SEND MAP('MENUMAP')
                      MAPSET('ACCTMS')
                      ...

Question 25

A COBOL CICS program performs a READ with UPDATE but encounters an error before it can REWRITE. What happens to the record lock, and how should the program handle this?

Show Answer When a READ with UPDATE acquires an exclusive lock on a VSAM record but the program does not issue a REWRITE (or UNLOCK or DELETE), the lock is **held until the task ends** or until an explicit action releases it. In a pseudo-conversational program, if the task issues RETURN TRANSID, the task ends and all locks are released. But if the program continues executing (perhaps performing other operations before returning), the lock blocks other tasks from accessing that record. The program should handle this by explicitly releasing the lock when it cannot complete the update:
       EXEC CICS READ FILE('ACCTFIL')
                      INTO(WS-ACCT-RECORD)
                      RIDFLD(WS-ACCT-KEY)
                      UPDATE
                      RESP(WS-RESP)
       END-EXEC

       IF WS-RESP = DFHRESP(NORMAL)
           PERFORM 5000-VALIDATE-CHANGES
           IF WS-VALIDATION-OK
               PERFORM 6000-REWRITE-RECORD
           ELSE
      *        Release the lock without updating
               EXEC CICS UNLOCK FILE('ACCTFIL')
                         RESP(WS-RESP)
               END-EXEC
               MOVE 'Validation failed' TO ERRMSGO
           END-IF
       END-IF
The UNLOCK command explicitly releases the exclusive lock acquired by the READ with UPDATE, allowing other tasks to access the record. In CICS TS V5 and later, you can also specify TOKEN on the READ UPDATE and REWRITE/UNLOCK to manage multiple concurrent locks.