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

DELETE FROM TABLE with rollback work

Former Member
0 Likes
3,227

Hi,

I try to do the command DELETE FROM TABLE for delete all regist that exist on database table from my internal table.

The command delete all the regist but i need to do a rollback work doesn't work. All the that are removed.

Anyone can help me to go back with delete data if i wan't to recovery data ?

Thank you in advance.

Miguel Silva

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,564

You must execute the ROLLBACK WORK before any DATABASE COMMIT.

Database Commit is triggered by COMMIT WORK, a call to DB_COMMIT or a native sql commit statement.

But it is also triggered Implicitly by end of dialog step, Call of a function module in a synchronous or asynchronous Remote Function Call or end of such a call, receive. Remember that sending a message, warning, error or information will trigger the end of a dialog step, so also trigger a db commit. (Read some documentation on [Database Commit|http://help.sap.com/abapdocu_70/en/ABENDB_COMMIT.htm])

Regards,

Raymond

4 REPLIES 4
Read only

Former Member
0 Likes
1,564

You have to do the rollback before the COMMIT or before the program ends. Did you do that?

Rob

Read only

Former Member
0 Likes
1,564

if you are using commit inside loop then take it out...

and use ROLLBACK WORK before the commit(based on your condition). here is the SAP help link. read to know more..

http://help.sap.com/abapdocu_702/en/abaprollback.htm

Read only

surajarafath
Contributor
0 Likes
1,564

try this code..

IF  itab IS NOT INITIAL.
    DELETE <db> FROM TABLE itab.
    IF sy-subrc NE 0 .
      ROLLBACK WORK.
      MESSAGE e0398(00)."Error while Saving data
      RETURN.
    ENDIF.
  ENDIF.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,565

You must execute the ROLLBACK WORK before any DATABASE COMMIT.

Database Commit is triggered by COMMIT WORK, a call to DB_COMMIT or a native sql commit statement.

But it is also triggered Implicitly by end of dialog step, Call of a function module in a synchronous or asynchronous Remote Function Call or end of such a call, receive. Remember that sending a message, warning, error or information will trigger the end of a dialog step, so also trigger a db commit. (Read some documentation on [Database Commit|http://help.sap.com/abapdocu_70/en/ABENDB_COMMIT.htm])

Regards,

Raymond