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

BAPI works individually but not inside a function module

Former Member
0 Likes
1,340

Hi everyone,

I have written a custom inbound iDoc processing function module where I am using the below function modules to create an operative network and activities within that network.

BAPI_PS_INITIALIZATION

BAPI_BUS2002_CREATE

BAPI_TRANSACTION_COMMIT

BAPI_NETWORK_MAINTAIN

After the last function module call I am doing COMMIT WORK AND WAIT and then BAPI_TRANSACTION_COMMIT and then executing another function module BAPI_NETWORK_COMP_ADD to create article components within the operative network activities. But this function module is not executing successfully and the e_message_table gives error that the activities does not exit.

The strange thing is that when I execute only BAPI_NETWORK_COMP_ADD in a separate test program with the same parameters hardcoded, it executes successfully.

I also tried the variations like STARTING NEW TASK and IN BACKGROUND TASK but still it is not working.

Can someone let me know if you have experienced this before and any other solutions which I can try?

3 REPLIES 3
Read only

GuyF
Active Participant
0 Likes
832

Hi,

Try using "IN UPDATE TASK". This makes the function (or BAPI in this case) to run when the program is saving the actual data, and judging by the BAPI names, the last BAPI is changing the object created in the second BAPI.

Guy.

Read only

Former Member
0 Likes
832

Thanks. I tried that now but it is giving me a short dump with message:

Non-update function module called for update.

Probably because this is a non update function module but I cannot turn it to an Update FM because I need to provide the exporting parameters since it is an iDoc posting FM.

Any other ideas?

Read only

Former Member
0 Likes
832

I solved the problem by myself.

For those who are still looking for the solution of this problem - refer to note 672750. As per this note you need to do some initialization. So just put a statement before BAPI_NETWORK_COMP_ADD call:

CALL FUNCTION 'CO_ZF_DATA_RESET_COMPLETE'.

and the problem will be solved.