The following is an example of a task-related user exit program.
id division.
program-id. SAMPTRUE.
environment division.
configuration section.
input-output section.
data division.
file section.
working-storage section.
linkage section .
copy 'dfhcbuxi.cpy'.
copy 'dfhcbuxc.cpy'.
01 lk-global-area.
03 lk-ga-byte pic x occurs 0 to 32767
depending on uxi-global-area-length.
01 lk-local-area.
03 lk-la-byte pic x occurs 0 to 32767
depending on uxi-local-area-length.
procedure division using
uxi-user-exit-interface.
module-entry-point.
move 0 to return-code
set address of lk-uxc-operation
to uxi-operational-flags-ptr
set address of lk-uxc-schedule-parm
to uxi-scheduling-flags-ptr
move 0 to lk-uxc-return-code
*> -- Are we being called by an application?
*> -- (User application sets unused value in lk-uxc-schedule.)
if lk-uxc-schedule = x'00'
perform called-by-application
goback
end-if
evaluate true
when lk-uxc-initialization-88
perform initialization
when lk-uxc-shutdown-88
goback
when lk-uxc-task-start-88
perform task-start-process
when lk-uxc-task-syncpoint-88
evaluate true
when lk-uxc-syncpoint-prepare-88
perform syncpoint-prepare
when lk-uxc-syncpoint-commit-88
perform syncpoint-commit
when lk-uxc-syncpoint-rollback-88
perform syncpoint-rollback
end-evaluate
when lk-uxc-user-syncpoint-88
set address of lk-global-area
to uxi-global-area-ptr
set address of lk-local-area
to uxi-local-area-ptr
evaluate true
when lk-uxc-syncpoint-prepare-88
continue
when lk-uxc-syncpoint-commit-88
perform syncpoint-commit
when lk-uxc-syncpoint-rollback-88
perform syncpoint-rollback
end-evaluate
end-evaluate
goback
.
called-by-application section.
*> -- Add any code here that you wish to execute when
*> -- called by an application program.
exit
.
initialization section.
$if 78-break-on-error defined
call 'CBL_DEBUGBREAK'
$end
perform set-schedule-bits
exit
.
task-start-process section.
*> -- Insert code here that you wish to perform at
*> -- start of task.
perform set-schedule-bits
exit
.
end-task-process section.
*> -- Insert code here that you wish to perform at
*> -- end of task.
exit
.
syncpoint-prepare section.
*> -- Insert code here that you wish to perform at
*> -- syncpoint prepare.
exit
.
syncpoint-commit section.
*> -- Insert code here that you wish to perform at
*> -- syncpoint commit.
exit
.
syncpoint-rollback section.
*> -- Insert code here that you wish to perform at
*> -- syncpoint rollback.
exit
.
set-schedule-bits section.
initialize lk-uxc-schedule-byte
*> -- Register start of task interest
compute lk-uxc-schedule-byte-bin =
lk-uxc-schedule-byte-bin B-OR 78-lk-uxc-TRUE-on-start
*> -- Register syncpoint interest
compute lk-uxc-schedule-byte-bin =
lk-uxc-schedule-byte-bin B-OR 78-lk-uxc-TRUE-on-sync
*> -- Register prepare interest
compute lk-uxc-schedule-byte-bin =
lk-uxc-schedule-byte-bin B-OR 78-lk-uxc-TRUE-on-prep
exit
.