Application Development 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: 

Wait in Asynchronous Function Module

Former Member
0 Kudos
1,299

Hello,

We are creating calling Asynchronous function module in the Delivery User Exist to create Invoice. Invoice creation needs to wait until delivery change is commited. For this purpose, we have placed ENQUEUE_SLEEP FM in the asynchronous FM with a wait time of 1 second. We have written a logic in such a way that ENQUEUE_SLEEP is called in a loop causing a delay of one second until delivery can be locked successfully.

But we cant let it wait for one second. Delivery should be locked as soon as delivery is committed in the main program. How can we achieve this in asynchronously called FM.

Thanks

3 REPLIES 3

kesavadas_thekkillath
Active Contributor
0 Kudos
304

Invoice creation needs to wait until delivery change is commited. For this purpose, we have placed ENQUEUE_SLEEP FM in the asynchronous FM with a wait time of 1 second. We have written a logic in such a way that ENQUEUE_SLEEP is called in a loop causing a delay of one second

Why are you going for this approach ? You can create a remote enabled fm and call it in background task as seperate unit in your user exit..

0 Kudos
304

I am following the exact approach of calling remote enabled FM in background task in seperate unit to create invoice. But This FM has to wait till delivery is committed. For this purpose, I am continuously trying to lock delivery after making it wait for 1 second.

But sometimes this 1 second is long enough for user to open the delivery in change mode again. I want to lock delivery as soon as delivery change has been committed. How can I do it?

0 Kudos
304

>

> I am following the exact approach of calling remote enabled FM in background task in seperate unit to create invoice.

Bear in mind that asynch RFC(aRFC) & RFC as BACKGROUND TASK(transactional RFC or tRFC) are completely different. While the former is generally used for parallel processing, the latter is used to maintain the "atomicity" of an SAP LUW.

tRFC calls are registered in special DB tables(ARFCSSTATE & ARFCSDATA) & are executed once the COMMIT WORK statement is executed in the particular LUW.

Further read available on the F1 help.

BR,

Suhas