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

Execution of BAPI inside BADI

Former Member
0 Likes
1,173

Good day Gurus,

I implemented BAPI_RE_CN_CREATE inside a BADI.

The syntax that I use is CALL FUNCTION BAPI_RE_CN_CREATE IN BACKGROUND TASK. I used "IN BACKGROUND TASK" because without that, the function keeps on looping. After adding the command, the BAPI works. Here is my question, how can I retrieve immediately the contract number that the BAPI created? I hope you can help me.

Thanks in advance.

Elly

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
906

What do you mean by function keeps on looping ? Could you please explain the neccesity of the return value ?

The return value( contract number ) will be available in database if the transaction gets executed successfully.

Kesav

What do you mean by function keeps on looping ? Could you please explain the neccesity of the return value ?

The return value( contract number ) will be available in database if the transaction gets executed successfully.

Kesav

3 REPLIES 3
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
907

What do you mean by function keeps on looping ? Could you please explain the neccesity of the return value ?

The return value( contract number ) will be available in database if the transaction gets executed successfully.

Kesav

Read only

0 Likes
906

Hi Kesav,

We put the BADI in AFTER_SAVE Method. The code is like this......

if sy-ucomm = 'TRANS_NEXT'.

CALL FUNCTION BAPI_RE_CN_CREATE

importing

.

.

.

endif.

When the the system reach at CALL FUNCTION part, it does'nt execute it and it jumps back to "IF" condition part. We look for solution in the forum and someone suggest to put "IN BACKGROUND TASK" and we didi that. It works actually. But after excuting the CALL FUNCTION and search the contract that was save in VICNCN table, it was not updated yet.

OUr scenario is that we want to know what is the contract number being created after the CALL FUNCTION module because we have another requirement that we will use that field after creating the contract.

Elly

Read only

0 Likes
906

If the method AFTER_SAVE is triggered after the commit work of the transaction then the record will not be saved if you execute the function in background task, to check if this is the case add a bapi_transaction_commit after the bapi call. First of all let us know what is the badi you are using and the standard transaction being used.

Kesav