‎2006 Jun 06 9:19 AM
hi all,
how do you implement commit work? i have a code more or less like the following:
update db_tab_dtl from table i_dtl.
update db_tab_hdr from table i_hdr.
i want to make sure that both statement commits or rollback if atleast one fails. Sort of like the transaction block in SQL...
regards,
sid
‎2006 Jun 06 9:21 AM
Hi sid,
1. Simple
2. Just add two / three lines
3.
<b>COMMIT WORK.</b>
update db_tab_dtl from table i_dtl.
<b>if sy-subrc = 0.</b>
update db_tab_hdr from table i_hdr.
<b>COMMIT WORK.</b>
<b>endif.</b>
4. 1st line is optional.
regards,
amit m.
‎2006 Jun 06 9:21 AM
Hi,
first you see if both the internal tables it1 and it2 are populated checking for sy-subrc.
Just give the statement COMMIT WORK after updating the database tables.
update db1 from itab1.
if sy-subrc =0.
update db2 from itab2.
commit work.
endif.Regards,
Aswin
‎2006 Jun 06 9:21 AM
Hi sid,
1. Simple
2. Just add two / three lines
3.
<b>COMMIT WORK.</b>
update db_tab_dtl from table i_dtl.
<b>if sy-subrc = 0.</b>
update db_tab_hdr from table i_hdr.
<b>COMMIT WORK.</b>
<b>endif.</b>
4. 1st line is optional.
regards,
amit m.
‎2006 Jun 06 9:22 AM
Try this.
update db_tab_dtl from table i_dtl.
if sy=-subrc = 0.
update db_tab_hdr from table i_hdr.
if sy-subrc = 0.
commit work.
else.
rollback work.
else.
rollback work.
endif.
Regards,
Ravi
‎2006 Jun 06 9:24 AM
hi friend,
update db_tab_hdr from table i_hdr.
if sy-subrc eq 0.
update db_tab_dtl from table i_dtl.
if sy-subrc eq 0.
commit work.
else.
rollback work.
endif.
else.
rollback work.
endif.
Hope it solves your purporse..
Reward if helps..
Regards,
Yakub Shah
‎2006 Jun 06 9:24 AM
You keep these two statements under
PERFORM UPDATE ON COMMIT.
if status = 0.
commit work.
else.
rollback.
endif.
If everything OK in this perform the commit it else rollback it.
Regds
Manohar
‎2006 Jun 06 9:39 AM
describe i_dtl lines lv_i_dtl.
update db_tab_dtl from table i_dtl.
if sy-dbcnt = lv_i_dtl.
describe i_hdr lines lv_i_hdr.
update db_tab_hdr from table i_hdr.
if sy-dbcnt = lv_i_hdr.
commit work.
else.
rollback.
endif.
else.
rollback.
endif.
‎2006 Jun 09 3:52 AM