       identification division.

       author.     Micro Focus, Ltd.        Micro Focus, Inc.
                   Newbury, Berkshire       Palo Alto, California
                   United Kingdom           U.S.A.

                All rights reserved.
       
      *** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      *** NOTE: If you update this, then you also have to update the
      ***       copy, DFHUSYNC.SBL, that is shipped to customers.
      *** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      ***-------------------------------------------------------------*
      *** Revision History                                            *
      ***-------------------------------------------------------------*
      ***  $Log: dfhusync.cbl,v $
      ***  Revision 1.3  2001/09/10 15:15:58  PEH
      ***  Name change from MERANT to Micro Focus.
      ***
      ***  
      ***     Rev 1.2   10 Sep 2001 15:15:58   PEH
      ***  Name change from MERANT to Micro Focus.
      ***  
      ***     Rev 1.1   05 Oct 1995 18:06:00   NJF
      ***  nf-051 - Changed user syncpoint exit control such that
      ***           the correct flags are set before the call.
      ***           Added a server initialisation and shutdown call
      ***           to allow for database connect type operations
      ***           without the need for PLTPI. Modified the shipped
      ***           dfhusync sample program for new fields and extended
      ***           the comments for documentation purposes.
      ***  Modules: dfheserv.cbl dfhusync.cbl dfhusync.sbl dfhcbapi.cpy
      ***  
      ***     Rev 1.0   09 Feb 1995 18:33:56   AJD
      ***  New MCO source stream Feb 1995 - Initial Revision
      ***-------------------------------------------------------------*
       environment division.

       data division.

       working-storage section.

       01  ws-work.
           02  ws-save-control-ptr         pointer.

       linkage section.

       01  cics-user-task-exit-control.

           10  cics-user-task-exit-pptr    procedure-pointer.
           10  cics-user-task-exit-ctl     pic x.
               88  cics-user-exit-on-start-88      value x'80'.
               88  cics-user-exit-on-sync-88       value x'40'.
               88  cics-user-exit-on-prep-88       value x'20'.
               88  cics-user-exit-on-both-88       value x'c0'.
               88  cics-user-exit-on-all-88        value x'e0'.
               88  cics-user-exit-on-2p-commit-88  value x'60'.
               88  cics-user-exit-none-88          value x'00'.

           10  cics-syncpoint-requestor    pic x   comp-x.
               88  cics-user-syncpoint-88          value 0.
               88  cics-task-syncpoint-88          value 1.
               88  cics-task-start-88              value 2.
nf-051         88  cics-initialization-88          value 254.
nf-051         88  cics-shutdown-88                value 255.

           10  cics-syncpoint-action       pic x   comp-x.
               88  cics-syncpoint-commit-88        value 0.
               88  cics-syncpoint-rollback-88      value 1.
nf-051*        88  cics-syncpoint-commit-cont-88   value 2.
nf-051*        88  cics-syncpoint-prepare-88       value 3.
nf-051         88  cics-syncpoint-prepare-88       value 2.

           10  cics-syncpoint-exception    pic x   comp-x.
               88  cics-syncpoint-normal-88        value 0.
               88  cics-syncpoint-failure-88       value 1.
               88  cics-syncpoint-rolledback-88    value 2.

           10  cics-user-task-number       pic x(4) comp-5.

       procedure division using cics-user-task-exit-control.

           *> -- This entry is called once on startup

           set cics-user-task-exit-pptr
                                       to entry 'userpvt'
           set cics-user-exit-none-88  to true

           set ws-save-control-ptr     to address of
                                          cics-user-task-exit-control
           exit program
           .

       entry 'userpvt'.

           *> -- This entry is called per the "exit-on" flags.

           set address of cics-user-task-exit-control
                                       to ws-save-control-ptr

           evaluate true
            when cics-task-start-88
               *> -- Task start notification
               continue

            when cics-syncpoint-rollback-88
               *> -- Do a rollback
               continue

            when cics-syncpoint-prepare-88
               *> -- Do a prepare
               continue

            when other
               *> -- Do a commit
               continue

           end-evaluate

           exit program
           .
      ***-------------------------------------------------------------*
      ***  $Workfile:   dfhusync.cbl  $ end
      ***-------------------------------------------------------------*
