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

Is BAPI_TRANSACTION_COMMIT thread overlapping?

friendlycoder
Participant
0 Likes
2,320

Hi all

We have a huge amount of invoices to book. So we have decided to split the invoices into small blocks and run the booking on several threads to improve the speed.

After the invoice booking BAPI is executed, we need to call of BAPI_TRANSACTION_COMMIT to finalize the commit. The question is, where do I have to call BAPI_TRANSACTION_COMMIT, on main or on every spawned thread?

Thanks

9 REPLIES 9
Read only

maheshpalavalli
Active Contributor
0 Likes
2,217

I believe you should call bapi transaction commit for every invoice bapi call.

You should call it because the invoice might update some tables which need the latest data (internally it might read the latest data from tables and might reupdate it ). I once got an issue of data inconsistency in the system tables, because we were doing bapi_trasaction commit for multiple bapi calls at once.

and your question of running it in multiple threads, I don't think calling bapi transaction commit in the main program will affect the threads bapis

Read only

Sandra_Rossi
Active Contributor
2,217

I guess that 1 thread = 1 SAP work process.

Each SAP work process is bound to one database process. A database commit applies to only its current database process. BAPI_TRANSACTION_COMMIT does one database commit (+ some ABAP buffer refresh + execute ABAP update tasks).

So...

Read only

0 Likes
2,217

@sandra.rossi

Are you sure, that 1 thread = 1 SAP work process? If yes, calling BAPI_TRANSACTION_COMMIT in the main thread does not do the commit on worker threads?

Thanks

Read only

0 Likes
2,217

I'm not sure, it's just my opinion. But why are you talking about "threads". Threads don't exist in SAP systems. There are only work processes. Moreover you mix SAP and database notions. The commit at database level is not performed by SAP work process, the commit is at database level. One database transaction is linked to exactly one SAP work process.

Anyway, there's no relationship between work processes, how would a "main" work process be aware that another one is its "child"?

Read only

0 Likes
2,217

bifunctor Why don't you want to code it the same way like SAP and other developers do it? i.e. do commit by package (each package can be processed by a dedicated work process, with a unique commit at the end). Do you have a reason to not want to do it? NB: in case it's your question, you cannot commit a big number of updates at once, the database would crash.

Read only

0 Likes
2,217

@Sandra Rossi

Thanks for your advice. However I think I have found a solution:

  DATA(lo_inbound) = cl_bgrfc_destination_inbound=>create( dest_name = 'YCAS1' ).
  DATA(lo_trcf) = lo_inbound->create_trfc_unit( ).


  CALL FUNCTION 'ZAMAR_BG_PROCESS' IN BACKGROUND UNIT lo_trcf
    EXPORTING
      iv_num = 20.

Thanks

Read only

0 Likes
2,217

Okay, so you do it by package.

Read only

former_member717457
Participant
2,217

Hi,

Apply BAPI_TRANSACTION_COMMIT When you split the invoices using internal table (loop). After Booking the invoice BAPI_TRANSACTION_COMMIT has to come.

Thanks

Sathish Kumar Sidhaiyan

Read only

0 Likes
2,217

Yes, but it does not work properly.