Sample code for a TRUE started by the CICS sync point manager

This example pseudocode shows you some of the conditions that a task-related user exit started at a sync point might be required to check.

Figure 1. Sample pseudocode for a task-related user exit program to be started by the CICS sync point manager
if UERTFID = UERTSYNC then       /* Caller is CICS syncpoint manager */
  select;                        /* Type of syncpoint manager request */
    when (UERTONLY)                          /* ONLY resource manager */
        invoke RM for single-phase commit    /* Single-phase commit */
        if RM single-phase commit succeeded then
          give CICS syncpoint manager 'YES' vote (UERFOK)
        else                         /* Single-phase commit failed */
                                     /* If RM completed backout */
          if RM single-phase commit failed and backed out
            give CICS syncpoint manager 'NO' vote (UERFBOUT)
          else                       /* Don't know what happened */
            put out message and issue transaction abend
          endif
        endif
    when (UERTELUW)                  /* RM read-only for current UOW */
        invoke RM for single-phase commit    /* Single-phase commit */
    when (UERTPREP)       /* Not ONLY resource manager, nor read-only */
        invoke RM for PREPARE  /* Prepare - phase 1 of 2-phase commit */
        select (resource manager vote)
          when (YES)                 /* Phase 1 completed */
            give CICS syncpoint manager 'YES' vote (UERFPREP)
          otherwise
            give CICS syncpoint manager 'NO' vote (UERFBACK)
        endselect
    when (UERTCOMM)             /* Commit - phase 2 of 2-phase commit */
      invoke RM for commit phase 2
      if RM commit succeeded then
        tell CICS sync manager OK (UERFDONE)
      else
        tell CICS sync manager remember could not commit (UERFHOLD)
      endif
    when (UERTBACK)                  /* Backout request */
      invoke RM for backout
      if RM backout succeeded then
        tell CICS sync manager OK (UERFDONE)
      else
        tell CICS sync manager remember could not backout (UERFHOLD)
      endif
    when (UERTWAIT)                  /* CICS indoubt about UOW */
      invoke RM to free thread
         (but maintain locks for UOW and record UOW is indoubt)
  endselect
endif

As described in Increasing efficiency: single-update and read-only protocols, if the UERTONLY bit is set (indicating that the resource manager is the only one to have updated resources) the exit program should cause the resource manager to perform a single-phase commit. If the commit is successful, the exit program should return ‘UERFOK' in register 15; if not, it should return ‘UERFBOUT', meaning that the commit was unsuccessful and the resources were backed out. If the exit program is unsure about the outcome of a single-phase commit, it should abend the task, having saved or displayed any diagnostic information that it considers necessary.

Note that “register 15” in this section refers to the sync point manager's register 15, the fifth word of the area addressed by UEPHMSA.

Similarly, when the UERTELUW bit is set (indicating that the resource manager was in read-only mode throughout this UOW), the exit program should cause the resource manager to perform a single-phase commit. There are no return codes for a UERTELUW call. Because no updates were made, data integrity is not at risk, and therefore no action is taken if the commit fails.

On receiving a request to perform the first phase of a two-phase commit, the resource manager is expected to get into a state where recoverable changes made since the last sync point can be either committed or backed out on demand, even if there is an intervening system failure. For example, buffer contents should be moved to nonvolatile storage. If the resource manager is unable to get into this state, the exit program should return ‘UERFBACK' in register 15, to request backout. Normally, it should return ‘UERFPREP', to indicate a successful phase 1 of a 2-phase commit.

On receiving a request to wait (indicating that CICS is indoubt about the outcome of the UOW), the resource manager should free any task-related resources, such as the thread. However, it should maintain any locks held by the UOW, and record that the UOW is indoubt. See Enabling for specific invocation-types.

On receiving a request to perform the second phase of a two-phase commit, or a request to back out, the resource manager should take the corresponding irreversible step, and have the exit program send the sync point manager a return code: either ‘UERFDONE', meaning that the commit or abend process is complete; or ‘UERFHOLD', meaning that the commit or abend should be resolved later. These return code constants are available to you when you code the macro DFHUEXIT TYPE=RM in your exit program.

If a resource manager cannot understand a call, it should not change the contents of the caller's register 15 before returning to the caller, because it cannot anticipate how the caller interprets the change.