Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

execute a function after event

Former Member
0 Likes
2,156

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,983

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

9 REPLIES 9
Read only

Former Member
0 Likes
1,983

Hi Dan,

I didn't find any after event program execution in requirement / post.

Thanks & Regards

Manu S

Read only

0 Likes
1,983

event is when zfct2 is available, when it's not running (executed from another program)...did you get it?

Read only

ThomasZloch
Active Contributor
0 Likes
1,983

For better understanding, what is it that zfct1 does that requires such an exclusive mode?

Thomas

Read only

0 Likes
1,983

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.

Read only

0 Likes
1,983

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

Read only

Former Member
0 Likes
1,983

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..

Read only

0 Likes
1,983

it's not working.

gobal parameter...did you mean to declare a variable in main program?

Read only

Former Member
0 Likes
1,984

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

Read only

0 Likes
1,983

it works with lock objects.

thank you.