Purging CICS DB2 transactions
Take care when purging CICS DB2 transactions to ensure that DB2 requests are not cancelled during "must complete" activity.
About this task
CICS applications that access DB2 do not enter a CICS wait state, because the CICS DB2 task-related user exit and the request into DB2 run on an L8 open TCB. In this environment, both purge and forcepurge of the CICS task are supported. However, with both of these there is again a risk of terminating a DB2 request during a “must complete” activity in DB2.
DB2 “must complete” activities are short-lived, but to avoid this risk, a safer way to terminate a CICS DB2 application is to use the DB2 CANCEL THREAD command. If the CICS DB2 task is active in DB2 at the time, then the thread is terminated, and “must complete” activity is either avoided, or completed before termination. If the task is not active in DB2 at the time of the cancel, then the cancel is deferred until DB2 is next accessed using that thread. Once the DB2 CANCEL THREAD command has been issued, you can safely issue a forcepurge of the CICS transaction, if needed (because the task is currently active in CICS rather than in DB2).
To determine which DB2 thread is associated with a CICS task, use the DSNC DISPLAY TRAN command (see DSNC DISPLAY), which shows the CICS task number, transaction id, and the 12–byte DB2 correlation id of the associated DB2 thread used by the CICS DB2 task. This correlation id uniquely identifies a thread. A DSNC —DIS THD(*), issues a DB2 display thread command showing all threads used by this CICS system identified by correlation id, and gives a unique token that can be used with a DB2 CANCEL THREAD command to cancel the thread.