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

LUW BAPI_TRANSACTION_COMMIT and Custom table Update

0 Likes
984

I call a BAPI. If the return table contains an error message I immediately call BAPI_TRANSACTION_ROLLBACK. Otherwise, I attempt to perform an update to a custom table. If the custom table update fails I call BAPI_TRANSACTION_ROLLBACK.

If the custom table update is successful I call BAPI_TRANSACTION_COMMIT. I want the BAPI commit and table update to exist as a LUW. If the custom table update fails I want to rollback the BAPI. I'm wondering if the attempt to update the custom table will automatically commit the prior database changes associated with the BAPI call. Also, I'm assuming I would not need to call COMMIT WORK or ROLLBACK WORK.

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
752

I guess you mean you have this code?

CALL FUNCTION 'BAPI'.
UPDATE yourtable SET column = 1 WHERE key = ...
IF sy-subrc <> 0. " unique key constraint error
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.

If the BAPI updates tables via an update task, there can be theoretically a difference if the update task aborts, your table will be updated but not the tables updated by the BAPI. In that case, you should update your table in the update task to reduce the risk.