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: 

Update rollback issue

Former Member
0 Kudos

Hi Friends,

I have a requirement where i need to read data from 4 standard tables then write the entries to 4 Ztables then delete the entries from the standard tables.

the sequence is read a standard table write it to ztable then delete the entries from standard table.

this occurs 4 times since 4 table are read and written into a ztable.

but all work should rollback if an error occur.

but currently when the 3rd table write fails when executed rollback work the 1st and 2nd table work has not been rollbacked is there anyway that i can achieve this requirement

Thanks

Nafran

7 REPLIES 7

ThomasZloch
Active Contributor

Are you using any ABAP statements inbetween that leave the internal session, e.g. SUBMIT, CALL TRANSACTION and the likes?

These would invoke a database commit.

Thomas

Former Member
0 Kudos

no nothing like that is used.

the code is in bellow sequence

select data from table 1

updated ztable1

if successful

delete table 1 entries

if successful

select data from table 2

updated ztable2

if successful

delete table 2 entries

Former Member
0 Kudos

This could be done with internal tables, saving the records to delete from each table, and only deleting them when the 4 conditions checked. This way you won't depend on rollbacks.

Former Member
0 Kudos

Hi,

For situations like this we should always use the concept of LUW.

Read this lik carefully:

[http://help.sap.com/saphelp_nw70/helpdata/EN/41/7af4bfa79e11d1950f0000e82de14a/content.htm]

The database update statements should be written in Special function modules called as UPDATE FUNCTION MODULE or

PERFORM xyz ON COMMIT and then commit should be executed when the Update FMs for all your transactions have been completed.

I am sure this is what you need.

Thanks,

Prakash Pandey

0 Kudos

but this is written in report program which makes it a single LUW

Pawan_Kesari
Active Contributor
0 Kudos

Did you happen to test this program in debug mode ?

0 Kudos

Commit should be used after all the 4 update .

if error occurs

rollback .

else.

commit work.

endif.