Quiz: Advanced CICS Programming
Multiple Choice
1. Which CICS command writes data to a Temporary Storage Queue?
a) WRITEQ TD b) WRITEQ TS c) PUT CONTAINER d) WRITE TEMPSTORE
2. What is the recommended practice for naming TSQs in a multi-user CICS environment?
a) Use the program name as the queue name b) Include the terminal ID (EIBTRMID) in the queue name c) Use a fixed 8-character name shared by all users d) Use the transaction ID as the queue name
3. What happens when you read from a Transient Data Queue (TDQ)?
a) The item remains in the queue for other readers b) The item is deleted from the queue (destructive read) c) The item is marked as read but not deleted d) The read fails if another task has the queue open
4. Which CICS command starts a transaction asynchronously without waiting for it to complete?
a) LINK b) XCTL c) START d) TRIGGER
5. What does the started transaction use to retrieve data passed by the START command?
a) RECEIVE b) READQ TS c) RETRIEVE d) GET CONTAINER
6. What is the practical maximum size of a COMMAREA?
a) 256 bytes b) 4 KB c) ~32 KB d) Unlimited
7. In the channel/container model, what is a channel?
a) A network connection between CICS regions b) A named collection of containers c) A type of transient data queue d) A security mechanism for program communication
8. In a browse/scroll pattern, which CICS facility is most appropriate for storing the browse data between pseudo-conversational interactions?
a) COMMAREA b) Temporary Storage Queue (TSQ) c) Transient Data Queue (TDQ) d) Channel/Container
9. What RESP condition is returned when you try to read a TSQ that does not exist?
a) NOTFND b) QIDERR c) ITEMERR d) DISABLED
10. What is optimistic locking in the context of CICS update transactions?
a) Locking the record when the user starts editing b) Using ISOLATION LEVEL RR on all queries c) Including original values in the UPDATE WHERE clause to detect concurrent changes d) Holding DB2 locks across pseudo-conversational task boundaries
11. What CICS abend code indicates a program check (like division by zero or invalid address)?
a) AKCT b) ASRA c) AEY7 d) AICA
12. Which statement about TSQ storage options is correct?
a) MAIN storage TSQs survive CICS region restarts b) AUXILIARY storage TSQs are stored on DASD and can be recoverable c) All TSQs are automatically deleted when the CICS region restarts d) TSQ storage option cannot be specified by the application program
13. What is the trigger level in an intrapartition TDQ definition?
a) The maximum number of items the queue can hold b) The number of items at which CICS automatically starts a specified transaction c) The security level required to access the queue d) The timeout value for queue reads
14. When using channels and containers with LINK, how does the called program know its channel name?
a) The channel name is passed in the COMMAREA b) The called program uses EXEC CICS ASSIGN CHANNEL c) The channel name must be hardcoded in both programs d) The channel is always named 'DFHLINK'
15. What is the most common cause of ASRA abends in pseudo-conversational CICS programs?
a) Division by zero b) Accessing DFHCOMMAREA when EIBCALEN = 0 c) Using STOP RUN d) Stack overflow from recursive LINK calls
True or False
16. TSQ items can be read directly by item number (random access), while TDQ items can only be read sequentially. ___
17. The START command can specify a time delay before the transaction is initiated. ___
18. XCTL transfers control to another program and the called program eventually returns to the caller. ___
19. Orphaned TSQs (from abandoned sessions) are automatically cleaned up by CICS. ___
20. Channel/container programming has no practical size limit, unlike the ~32 KB limit of COMMAREA. ___
Short Answer
21. Compare and contrast TSQs and TDQs. Give two specific use cases where each is the better choice.
22. Explain why optimistic locking is preferred over pessimistic locking in CICS pseudo-conversational transactions. What would happen if you used pessimistic locking (SELECT FOR UPDATE) and the user left for a 10-minute coffee break?
23. A multi-screen CICS transaction has the following state machine: Search (S) → Browse (B) → Detail (D). The user can press PF3 to go back one level (D→B, B→S, S→Exit). Design a COMMAREA structure that supports this state machine, including the data needed for each screen.
24. Describe the TSQ cleanup problem (orphaned queues) and two strategies for addressing it.
25. A developer proposes using a TDQ instead of a TSQ for browse/scroll data. Explain why this would not work and what problems it would cause.
Answer Key
1. b) WRITEQ TS — TS = Temporary Storage.
2. b) Include the terminal ID (EIBTRMID) — ensures each user has a private queue.
3. b) The item is deleted from the queue — TDQ reads are destructive.
4. c) START — initiates a transaction asynchronously.
5. c) RETRIEVE — used by the started transaction to get the data.
6. c) ~32 KB — the architectural limit is higher, but practical concerns limit it to about 32 KB.
7. b) A named collection of containers — channels hold multiple named data items.
8. b) Temporary Storage Queue (TSQ) — it persists across tasks and supports random access by item number.
9. b) QIDERR — Queue ID Error, the queue does not exist.
10. c) Including original values in the UPDATE WHERE clause — if another user changed the record, the WHERE clause will not match and the UPDATE affects 0 rows.
11. b) ASRA — indicates a program check exception.
12. b) AUXILIARY storage TSQs are stored on DASD and can be recoverable.
13. b) The number of items at which CICS automatically starts a specified transaction.
14. b) The called program uses EXEC CICS ASSIGN CHANNEL to get the current channel name.
15. b) Accessing DFHCOMMAREA when EIBCALEN = 0 — the COMMAREA does not exist on first invocation.
16. True — TSQs support random access by item number; TDQs are strictly sequential (FIFO).
17. True — START supports INTERVAL and TIME options for delayed execution.
18. False — XCTL transfers control permanently; the calling program's storage is released and it does not return. LINK is the call-and-return mechanism.
19. False — CICS does not automatically clean up orphaned TSQs. Applications must implement their own cleanup strategy (e.g., a periodic cleanup transaction).
20. True — channels and containers have no practical size limit, making them suitable for large data exchanges.
21. TSQs are indexed scratch pads: items can be read by number, rewritten, and the queue persists until explicitly deleted. Best for: (1) browse/scroll data — load search results, read by page position; (2) multi-screen state data too large for COMMAREA. TDQs are sequential event channels: reads are destructive and items are processed in FIFO order. Best for: (1) audit logging — write records sequentially, process them in a batch; (2) trigger-level processing — accumulate items until a threshold, then auto-start a processing transaction.
22. Pessimistic locking (SELECT FOR UPDATE) acquires a database lock that is held until COMMIT or ROLLBACK. In a pseudo-conversational transaction, the task ends after sending the screen — but the lock persists until the next task starts and commits. If the user takes a 10-minute break, the lock blocks all other transactions trying to access that record for 10 minutes. With thousands of concurrent users, this would cause widespread lock contention and timeouts. Optimistic locking avoids this by not holding locks during think time — it only checks for conflicts at update time, which is typically sub-second.
23. COMMAREA design:
01 WS-COMMAREA.
05 WS-CA-STATE PIC X(1). (S/B/D)
05 WS-CA-TSQ-NAME PIC X(8). (Browse queue name)
05 WS-CA-TOTAL-ITEMS PIC S9(4) COMP. (Total browse items)
05 WS-CA-TOP-ITEM PIC S9(4) COMP. (First item on current page)
05 WS-CA-PAGE-SIZE PIC S9(4) COMP. (Items per page, e.g., 15)
05 WS-CA-SEARCH-KEY PIC X(20). (Search criteria for rebuild)
05 WS-CA-SELECTED-KEY PIC X(15). (Key of selected row for detail)
The search key is preserved so PF3 from Browse can redisplay Search with the previous criteria. The selected key lets Detail know which record to display. Top-item preserves the scroll position so returning from Detail shows the same page.
24. The TSQ cleanup problem: when a user closes their terminal emulator or network connection drops, the pseudo-conversational program never reaches its PF3/exit cleanup logic, leaving the TSQ in CICS storage indefinitely. Strategy 1: Implement a cleanup transaction (e.g., CLNP) that runs periodically via START INTERVAL, browses all TSQs matching application prefixes, and deletes those that are stale (based on a timestamp stored in the first item). Strategy 2: At the start of every transaction's first invocation, attempt to DELETEQ TS the queue before creating a new one — this catches queues orphaned by the same terminal ID.
25. TDQ reads are destructive — once you read an item, it is gone from the queue. In a browse/scroll pattern, the user needs to page backward (PF7), which requires re-reading items already displayed. With a TDQ, those items would already be consumed. You would need to maintain a separate buffer of previously read items, which defeats the purpose. Additionally, TDQs do not support random access by item number (needed for FETCH ABSOLUTE-style positioning). TSQs support both — random access by item number and non-destructive reads — making them the correct choice for browse/scroll patterns.