Application Development 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: 

Roll Back custom table updates if report dumps before COMMIT

Former Member
0 Kudos
560

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.

1 REPLY 1

raymond_giuseppi
Active Contributor
105

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