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: 

How to run Multiple BAPI's as single transaction

jallipalli_sai
Explorer
0 Kudos

Hello Experts,

We are trying to call multiple bapi's in a below sequence .

1) BAPI_BUS2054_CREATE_MULTI

2) BAPI_ALM_ORDER_MAINTAIN

As per requirement WBS created in step1 in have to pass to step2 and create the work order.

So for that I am committing the transaction after each bapi call.

But now the requirement is either we have to create WBS and Work order or none of them so I am using only one commit transaction at the end of the both the calls. which is not working.

Please let me know how to achieve this functionality.

Thanks in advance

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

That's the limit of LUW model. You must commit the first one to get the WBS number, and if the second BAPI fails you can't rollback the first one.

To avoid this issue, I think the best workaround is to define a restart procedure, to restart the second BAPI. You may reuse either existing mechanisms (bgRFC/tRFC/qRFC for instance), or remember the exact situation via a custom database table and define a restart program...

5 REPLIES 5

SimoneMilesi
Active Contributor

Hello!

You cannot use just a single commit work, because otherwise the 2nd BAPI cannot find the object from the 1st one, since without commit the changes are not pushed to the db (over semplified explaining).

What i'd do is something like:

- BAPI_BUS2054_CREATE_MULTI

- If error, message and exit

- else, commit

- BAPI_ALM_ORDER_MAINTAIN

- if ok, commit

-else, rollback and

BAPI_BUS2054_DELETE_MULTI

I hope i've been clear with what i've in mind.

0 Kudos

Hi Simone

Thanks for suggestion, the issue after creating the Work order using it we are also creating some other dependent objects on it such as cu design, cu order etc.

So at the final step or after creating work order in further steps if any error happens as per my understand we can't delete the work order once it was commit which will be a problem.

If I am wrong please let me know I am new to this process.

Hello sai898.

As suggested by sandra.rossi , you have to find a method to keep track about the flow of object you are creating and give to the users a dashboard to reprocess the missing data or delete the created ones.

For work order, i think you can use the DELETE option (table method) of the BAPI_ALM_ORDER_MAINTAIN or, if you cannot, set the system status.

Sandra_Rossi
Active Contributor

That's the limit of LUW model. You must commit the first one to get the WBS number, and if the second BAPI fails you can't rollback the first one.

To avoid this issue, I think the best workaround is to define a restart procedure, to restart the second BAPI. You may reuse either existing mechanisms (bgRFC/tRFC/qRFC for instance), or remember the exact situation via a custom database table and define a restart program...

0 Kudos

Hi Sandra ,

Thanks for the response .

I understood the logging the details via custom table and using it while restarting process.

But I would like to know how can we use existing mechanisms (bgRFC/tRFC/qRFC for instance) as you mentioned.

If you elaborate it with an example it will be very helpful.