Skip to Content
avatar image
Former Member

Roll Back custom table updates if report dumps before COMMIT

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 16, 2017 at 06:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded