Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BAPI_TRANSACTION_COMMIT with WAIT = 'X' within a BADi

What would be the effect of using the 'BAPI_TRANSACTION_COMMIT' with 'WAIT' parameter when equals to 'X' inside a BADi? Should I expect that SAP will commit the data when LUW commits?

I'm aware that inside 'BAPI_TRANSACTION_COMMIT' it happens 'COMMIT WORK' or 'COMMIT WORK AND WAIT' if you specify parameter 'WAIT' = 'X'.

I'm also aware that it's not correct to make a 'COMMIT WORK' inside a BADi, but if I use 'COMMIT WORK AND WAIT' via the BAPI?

The SAP documentation regarding to COMMIT says:

This executes all high-priority (VB1) update function modules in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating), but instead is resumed immediately after COMMIT WORK. However, if the addition AND WAIT is specified, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

When all high-priority update function modules are completed successfully, the statement executes the low-priority (VB2) update function modules in the order of registration together in a common database LUW.

My confusion arises because we have a BADi implementation where there's a call to the mentioned function with parameter 'WAIT' = 'X' and we have found a SAP Notes where it prohibits the use of 'COMMIT WORK' inside that BADi, however it says 'COMMIT WORK' and not 'COMMIT WORK AND WAIT'.

So I could think that the implementation is right because that data would be commited when LUW finishes ... or not. Any comments?

like image 677
Nelson Miranda Avatar asked Oct 21 '14 19:10

Nelson Miranda


1 Answers

Actually the LUW finishes when you call COMMIT WORK or COMMIT WORK AND WAIT. The only difference is that COMMIT WORK is asynchronous and COMMIT WORK AND WAIT is synchronous.

The BAPI_TRANSACTION_COMMIT with WAIT parameter set is equal to COMMIT WORK AND WAIT. Without the parameter set it is equal to COMMIT WORK.

And it is true. You must not commit in a BAdI. What if there is a rollback after the BAdI has already executed? It could leave your data in a totally inconsistent state.

like image 69
Jagger Avatar answered Oct 20 '22 06:10

Jagger