‎2009 Oct 11 3:41 PM
Hi all,
Need your expert opion/view on this, which one is more efficient, to put the 'BAPI_TRANSACTION_COMMIT' call right after bapi posting call in loop OR put the bapi commit call statement at the end of the process (after looping). This is one of the area in interface program that need can be improved to make the database update and table locking run efficiently. Let say there are 1000 documents (in loop) that need to be posted.
EXAMPLE:
Solution 1: To put commit right after bapi posting in loop:
loop at itab.
CALL 'BAPI_ACC_DOCUMENT_POST'
...............................................
CALL 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
endloop.
Solution 2: To put commit at end of process (after loop)
loop at itab.
CALL 'BAPI_ACC_DOCUMENT_POST'
...............................................
endloop.
CALL 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
Which one is more efficient and faster? solution 1 or 2?
Thanks all.
Edited by: Ahmad Ariza Abdullah on Oct 11, 2009 4:41 PM
‎2009 Oct 12 4:59 AM
Hi,
Better solution is to put Commit FM inside the loop. IF document is succefully posted , call commit bapi otherwise call Rollback bapi. Aslo pass Wait parameter in BAPI.
Regards,
Rajneesh
‎2009 Oct 12 5:06 AM
U need to commit only if the BAPI executed correctly without any errors...
loop at itab.
CALL 'BAPI_ACC_DOCUMENT_POST'
...............................................
if sy-subrc eq 0.
CALL 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
endif.
endloop.
‎2009 Oct 12 7:17 AM
Thanks for all replies.
Let say there are 30000 documents have been posted via BAPI in program without immediate commit call in loop, where exactly SAP will store the updates details before the updates will be commited at the end of process? Can we check the details of each update? Appreciate if you can share documetation or your view on this.
How exactly SAP handle the BAPI call, request update(SM13) and commit statement?
Thanks in advance.
‎2009 Oct 12 7:44 AM
Hi Ahmad,
Every Bapi returns a message table i.e RETURN. If there is any error in execution of BAPI. This table will have an error message in it.
In your case, what you can do is to create one update function module, include BAPI_ACC_DOCUMENT_POST in this function module and update all the documents.
Now call your update function module with IN UPDATE TASK addtion, this way a LUW will be created.
Now call BAPI_TRANSACTION_COMMIT with import parameter WAIT = 'X'.
This way it will execute COMMIT WORK AND WAIT statement which returns a sy-subrc value.
If there is some error in your function module, you 'll get sy-subrc not equal to zero and no document will be updated.
Regards
Abhijeet
‎2009 Oct 12 12:22 PM
Unless and until you use a commit statement the BAPI will not commit, if the BAPI doesn't have auto commit in it.
Document number will be generated and it will be wasted, its better you commit after the successful bapi call.
Thanks,
Maehsh.
‎2009 Oct 12 9:29 AM
Hello Ahmed,
Why are you passing single entry in loop ?
first you should take all entry in one internal table filter as per you requirement in Loop final table you pass in BAPI then use COMMIT , ROLLBACK. it will trigger your BAPI once
Regards,
Sujeet