‎2006 Dec 05 5:24 AM
There is a record having many fields & I want to insert the record in 3 custom tables designed accordingly . but either all the tables should get filled or none of the table should get filled.Should I use commit/rollback?? How??
The following is the syntax in a function module.
INSERT ZTEST1 FROM ZTEST1.
INSERT ZTEST2 FROM ZTEST2.
INSERT ZTEST3 FROM ZTEST3.
IF SY-SUBRC = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
This does not work. Any Solution??
‎2006 Dec 05 5:30 AM
Hi,
If u want to check all the tables :
Try this:
INSERT ZTEST1 FROM ZTEST1.
IF SY-SUBRC = 0.
INSERT ZTEST2 FROM ZTEST2.
IF SY-SUBRC = 0.
INSERT ZTEST3 FROM ZTEST3.
IF SY-SUBRC = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
endif.
endif.
So u can check the commit work for all the three .
Hope this helps.
‎2006 Dec 05 5:32 AM
the code you are writte will check only third insert.<br>
do in the following way <br>
form save_data. <br>
INSERT ZTEST1 FROM ZTEST1.<br>
if sy-subrc = 0<br>
INSERT ZTEST2 FROM ZTEST2.<br>
if sy-subrc = 0<br>
INSERT ZTEST3 FROM ZTEST3.<br>
else.<br>
rollback work<br>
exit.<br>
endif.<br>
else.<br>
rollback work<br>
exit.<br>
endif..<br>
commit work.<br>
endform.
Message was edited by:
SHEFALI GANGRADE
‎2006 Dec 05 6:49 AM
Hi Deepali,
1. Never ever use a insert to pdate any table , always use a function module in
update mode, this is the best industry practise.
2. Use all the three insert statements insde a custom function module in
update mode, this will udate all if sucess and roll back if any one fails.
Regards,
Vaibhav B Gawali.
‎2006 Dec 05 7:00 AM
Hi,
The following code will helps to you.
INSERT ZTEST1 FROM ZTEST1.
if sy-subrc ne 0.
rollback work.
exit.
endif.
INSERT ZTEST2 FROM ZTEST2.
if sy-subrc ne 0.
rollback work.
exit.
endif.
INSERT ZTEST3 FROM ZTEST3.
if sy-subrc ne 0.
rollback work.
exit.
endif.
commit work.Regards
Bhupal Reddy