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

On commit work and LUW...

Former Member
0 Likes
954

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
895

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.

7 REPLIES 7
Read only

Former Member
0 Likes
895

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

Read only

Former Member
0 Likes
896

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.

Read only

Former Member
0 Likes
895

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

Read only

Former Member
0 Likes
895

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

Read only

Manohar2u
Active Contributor
0 Likes
895

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

Read only

Former Member
0 Likes
895

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.

Read only

Former Member
0 Likes
895

thanks to all of you guys!...