Was just curious, Is possible to establish an end of task activity?
Well, usually in a typical DB2 batch application, the main program is either called the DSN program (TSO Attach) or calls a main Call Attach Facility which controls the connectivity with DB2.
Basically, I'm trying to do is to create a Smart CAF (Call Attach Facility) utility.
While experimenting, I noticed that our Cobol code is compiled with the DYNAM compile option, which in turns dynamically calls the DSNHLI SQL interface module.
However, I figured out how to create an alias of this module in my load library which calls my utility. Basically, my utility when called for the first time, establish the necessary connectivity with DB2, loads a copy of itself and passes control to the real DB2 interface module. In essences it terminates and stays resident (TSR), since it’s load count does not go down to zero.
My dilemma, is how to determine when the last program is executed, so that I can perform the final disconnect from DB2. I know to locate the current TCB information, but I cannot seem access the end of task activity routine. Although, the address of Save Area of the first program in task is listed in the TCB map, it does not appears addressable.
I not sure if there is a way to establish/schedule an end of task routine in this context.