Skip to Content
0

Roll Back custom table updates if report dumps before COMMIT

Feb 16, 2017 at 05:52 AM

46

avatar image

Hi,

I'm deleting all records from a custom table as the very first statement. After some 1000 line of codes I'm doing COMMIT WORK. If my program dumps in between I want all records in table as it is(NOT DELETED), but i find that my table is empty. Here is sample code below.

DELETE FROM ztest.

*****Some thousand line of codes.*** My program may dump here in between

IF sy-subrc eq 0.

COMMIT WORK.

ENDIF.

Please help me how to roll back custom table changes, if my report dumps in between.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Raymond Giuseppi
Feb 16, 2017 at 06:39 AM
1

Look in your code for any Implicit Database Commits, are you able to remove those, in this case a database rollback will reverse the delete (e.g. call FM DB_ROLLBACK)

If not, then you can no longer reverse the changes so consider moving the delete and following insert open-sql statements to some update function module called IN UPDATE TASK, so they won't be executed before the COMMIT-WORK.

Else you could load ZTST initial values in an internal 'old' table, remove the open-sql statements in the code, replace by adding records in an internal 'new' table and just before the COMMIT, update the database table.

Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded