‎2012 Jan 26 8:44 AM
Hi experts,
i want to execute a function after a event. I give you an example:
Zprogram1call function zfct1.
While execution of function zfct1is running, zprogram2 call function same function zfct1.
But it's possible that function execution from zprogram2 to run only after function execution from zprogram1 is finished? I mean , function execution from zprogram2 to sart delayed...only when zfct1 is available,when it's not running in other process.
Many thanks.
Dan M.
‎2012 Jan 26 2:23 PM
Hi Dan,
When zfct1 is executing from zprogram1, lock the DB tables it is accessing using ENQUEUE_XXXXX function module.
So the table is locked exclusively for the current instance and the zprogram2 cannot access the same DB table till you unlock it.
After DB table update, dont forget to unlock the same using DEQUEUE_XXXXX function module.
I hope the above will suffice your requirement.
Cheers,
Raja.D
‎2012 Jan 26 8:52 AM
Hi Dan,
I didn't find any after event program execution in requirement / post.
Thanks & Regards
Manu S
‎2012 Jan 26 8:55 AM
event is when zfct2 is available, when it's not running (executed from another program)...did you get it?
‎2012 Jan 26 9:16 AM
For better understanding, what is it that zfct1 does that requires such an exclusive mode?
Thomas
‎2012 Jan 26 9:19 AM
ZFCT1 do some selects and updates in db tables and return a value...so, after updates are not complete, i don't want to execute this function, because this will lead to false result.
‎2012 Jan 26 1:45 PM
Hello Dan
To control this behavior you can use EXCEPTIONS when defining the function module, then when calling this from a Program it can be handled via SY-SUBRC return code
Best regards
‎2012 Jan 26 2:23 PM
you can go for
CALL FUNCTION func STARTING NEW TASK task
and in the task id pass the same task name(any char variable of length max 8 chars).
so, what happens here is :
prog1 calls fct1 with task T1. (keeps running)
prog2 calls fct1 with task T1.(same T1, so the second call can also access the global variables from first call).
hence, you can have a global variable set to X in the fct1 before the update lines... and at the beginning of fct1 you can check that this global variable NE X. then only continue. else wait until that becomes blank
i have never tried this, but giving you a theory. try implementing it..
‎2012 Feb 04 3:23 PM
it's not working.
gobal parameter...did you mean to declare a variable in main program?
‎2012 Jan 26 2:23 PM
Hi Dan,
When zfct1 is executing from zprogram1, lock the DB tables it is accessing using ENQUEUE_XXXXX function module.
So the table is locked exclusively for the current instance and the zprogram2 cannot access the same DB table till you unlock it.
After DB table update, dont forget to unlock the same using DEQUEUE_XXXXX function module.
I hope the above will suffice your requirement.
Cheers,
Raja.D
‎2012 Feb 04 3:24 PM