2022 Jul 01 8:42 PM
Hello,
I've implemented P/S BTE 1030. The requirement is to post a follow on accounting document immediately after the original accounting document is posted. Inside the BTE I've an RFC-enabled wrapper FM(called in background task destination none) which calls the account posting BAPI followed by commit work. Is this the correct/recommended approach for achieving this requirement? More importantly, is it ok to use an explicit commit work inside the background LUW?
The statements COMMIT WORK and ROLLBACK WORK must not be executed within a LUW. In addition, no implicit database commit can be triggered there.
2022 Jul 02 9:09 AM
Hi Sanjay,
By thumb rule - it is recommended not to use the Explicit commit statements in the FM. However, in your case if you are calling the standard account posting BAPI (which is the last step) it is no harm.
Suppose if your previous process has some commits and your last Accounting BAPI failed, then there will be a data inconsistency.
If you are sure that your BAPI call (wrapper fm) is the final step and commits there - there is no issue i believe.
2022 Jul 02 5:41 PM
About the reason why SAP says not using COMMIT/ROLLBACK, I guess it breaks the concept of transactional RFC where one or more function modules should work inside one LUW, none should do COMMIT/ROLLBACK, so that any failure would rollback everything or success would commit everything.
Before and after calling the function module(s), SAP updates RFC system tables to update the state of the RFC unit (started, succeeded or failed). For instance, if you COMMIT/ROLLBACK and something goes wrong before the end of the RFC unit, it would not rollback the updates done by your function module (because you did a commit) and you'll see an error in SM58. You might have the possibility to restart the function module, although it would execute for the second time.
It's up to you to see if it's acceptable or not. I guess SAP would always say it's not acceptable.