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

Asynchronous call

bhakti2
Active Participant
0 Likes
1,252

Hi,

what is correct way to call SRM from ECC program asynchronously ? so that the  ECC program gets over even if SRM code is running.

call RFC function module in update task

or

PI scenario to trigger SRM code

ECC needs results so SRM needs to send results once SRM task is completed.

thanks for any inputs

bhakti

1 ACCEPTED SOLUTION
Read only

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert
0 Likes
1,185

Hi Bhakti,

"CALL FUNCTION IN UPDATE TASK" is basically a synchronous call, the difference being only that all inserts/updates to database tables are not performed directly on the tables, but in a temporary "update area", so they can be committed/rolled back later in one unit by the "update work process".

If you want an asynchronous communication to a different system, you need to use "CALL FUNCTION STARTING NEW TASK", e.g.

CALL FUNCTION 'MY_FUNC' STARTING NEW TASK 'my_task'

PERFORMING MY_FORM ON END OF TASK

DESTINATION 'my_dest'

EXPORTING ...

IMPORTING...

TABLES...

EXCEPTIONS...

And then you need a form routine like this, which will be triggered asynchronously, when the results from the target system arrive:

FORM MY_FORM USING TASKNAME.

RECEIVE RESULTS FROM FUNCTION 'MY_FUNC'

IMPORTING ...

TABLES ...

EXCEPTIONS ...

....

ENDFORM.

See the ABAP doc of the CALL FUNCTION statement for more details and samples.

Best Regards, Ulrich

5 REPLIES 5
Read only

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert
0 Likes
1,186

Hi Bhakti,

"CALL FUNCTION IN UPDATE TASK" is basically a synchronous call, the difference being only that all inserts/updates to database tables are not performed directly on the tables, but in a temporary "update area", so they can be committed/rolled back later in one unit by the "update work process".

If you want an asynchronous communication to a different system, you need to use "CALL FUNCTION STARTING NEW TASK", e.g.

CALL FUNCTION 'MY_FUNC' STARTING NEW TASK 'my_task'

PERFORMING MY_FORM ON END OF TASK

DESTINATION 'my_dest'

EXPORTING ...

IMPORTING...

TABLES...

EXCEPTIONS...

And then you need a form routine like this, which will be triggered asynchronously, when the results from the target system arrive:

FORM MY_FORM USING TASKNAME.

RECEIVE RESULTS FROM FUNCTION 'MY_FUNC'

IMPORTING ...

TABLES ...

EXCEPTIONS ...

....

ENDFORM.

See the ABAP doc of the CALL FUNCTION statement for more details and samples.

Best Regards, Ulrich

Read only

0 Likes
1,185

hi Ulrich

we are already calling the same way

but my requirement is that the ECC program shud get 'completed'

the background job in sm37 should be completed, finished.

the program in SRM should have got started. and when it will get finished, then the results shud be sent back to ECC.

Starting new task is asynchronous in way of connection but as a functionality, the calling program is not finished while the RFC is running.

thanks

bhakti

Read only

0 Likes
1,185

Hi Ulrich and other gurus

do comment on the requirement how to achieve it.

Would this be another option - call remote function from ABAP in SRM, trigger an ABAP OOPS event, start another process as event handler , the remote function is completed so the ABAP process is complete. once the event handler is completed in SRM , it will update the Ztable in ECC with its results.

is it correct or feasible or is there a better approach ?

any comments, anything, any thoughts are welcome

thanks in advance

Read only

0 Likes
1,185

Hi Bhakti,

ok, as far as I understand the requirement now, you are looking for some kind of "messaging infrastructure": ECC sends a message to SRM, where it is stored in a queue. At some point of time a scheduler in SRM processes the message, and when it is finished, it sends a "response message" back to ECC. Here again a scheduler processes the response and updates the table.

Not sure, whether that can be achieved with out-of-the-box ABAP features. Perhaps the closest you can get would be to use "Background RFC" (bgRFC) with two queues (one outgoing, one incoming) on each of the two systems?!

An old-style approach would be to use ALE and exchange IDocs between the two systems?!

Best Regards, Ulrich

Read only

0 Likes
1,185

hi Ulrich

no my requirement is not messaging infrastructure

but from your description it could be one of the solutions to my requirement

I will check the bgRFC and ALE IDoc options

my only requirement is that my ECC program need not wait till the SRM work is finished because its taking too long. but then ofcourse I need the results of the SRM activity to log in ECC.

I don't have too much time and resource and need simplistic solution

thanks very much for sharing your knowledge, its very useful for me to design the solution to have your thoughts and ideas

thanks

bhakti