2009 Jun 02 7:33 AM
Hi Friends,
I am using
perform insert_header on commit level 1
perform insert_item on commit level 2.
commit work and wait
form insert_header.
INSERT zheader_table.
endform.
form insert_item.
INSERT zitem_table.
endform.
After the header records gets successfully gets created , for some reason if item records insertion fails i need to rollback the header records also
please give some suggestions
I had checked with SY_SUBRC check also before COMMIT WORK AND WAIT , but that value of SY_SUBRC check is not getting recognized
Edited by: Chandrasekhar Jagarlamudi on Jun 2, 2009 8:38 AM
2009 Jun 02 7:46 AM
Hi,
Try this way..
perform insert_header Changing g_subrc .
if g_subrc EQ 0.
perform insert_item Changing g_subrc .
if g_subrc EQ 0.
commit work and wait
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
commit work and wait
form insert_header Changing g_subrc .
INSERT zheader_table.
g_subrc = sy-subrc.
endform.
form insert_item Changing g_subrc .
INSERT zitem_table.
g_subrc = sy-subrc
endform.
2009 Jun 02 7:46 AM
Hi,
Try this way..
perform insert_header Changing g_subrc .
if g_subrc EQ 0.
perform insert_item Changing g_subrc .
if g_subrc EQ 0.
commit work and wait
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
commit work and wait
form insert_header Changing g_subrc .
INSERT zheader_table.
g_subrc = sy-subrc.
endform.
form insert_item Changing g_subrc .
INSERT zitem_table.
g_subrc = sy-subrc
endform.
2009 Jun 02 7:51 AM
Thanks Avinash,
In this if the Insert zitem_table fails , we are using ROLLBACK WORK , will it rollback the header details also ? i tried that and we it did not rollback header details
We have to define them as single LUW
2009 Jun 02 1:11 PM
HI,
If zitem_table fails it will rollback header details also...there was small mistake in my previous thread i forgaot to comment the Commit work and wait before form statement.
perform insert_header Changing g_subrc .
if g_subrc EQ 0.
perform insert_item Changing g_subrc .
if g_subrc EQ 0.
commit work and wait
ELSE.
ROLLBACK WORK.
ENDIF.
ELSE.
ROLLBACK WORK.
ENDIF.
form insert_header Changing g_subrc .
INSERT zheader_table.
g_subrc = sy-subrc.
endform.
form insert_item Changing g_subrc .
INSERT zitem_table.
g_subrc = sy-subrc
endform.
2009 Jun 02 1:24 PM
Thanks Avinash,
I had tried with this, header details are not rolledback
I had tried to insert a new record in header and then an existing record in item table,
So in this case as INSERT Item will fail , header insertion also should be rolledback
Please let me know if i am missing anything
PERFORM header CHANGING v_subrc.
IF v_subrc = 0.
PERFORM item CHANGING v_subrc.
IF v_subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ELSE.
ROLLBACK WORK.
ENDIF.
FORM header CHANGING v_subrc.
zheader_1-matnr = '1111'.
INSERT zheader_1.
v_subrc = sy-subrc.
ENDFORM. "header
FORM item CHANGING v_subrc.
zitem_1-matnr = '000012345'.
zitem_1-maktx = 'Matnr 1'.
v_subrc = sy-subrc.
ENDFORM.
Edited by: Chandrasekhar Jagarlamudi on Jun 2, 2009 2:24 PM
2009 Jun 02 1:31 PM
Hi,
FORM item CHANGING v_subrc.
zitem_1-matnr = '000012345'.
zitem_1-maktx = 'Matnr 1'.
INSERT zitem_1. " Missing this line
v_subrc = sy-subrc.
ENDFORM.
2009 Jun 02 2:35 PM
2009 Jun 02 7:49 AM
Hi,
After the 'INSERT' statement check the sy-subrc value. If it not equal to 0, then exit the process.
cheers
gaurav
2009 Jun 02 7:49 AM
Try with this logic:
perform insert_header on commit level 1
form insert_header.
INSERT zheader_table.
if sy-subrc = 0.
perform insert_item on commit level 2.
commit work.
else.
rollback work.
endif.
endform.
Mahesh
2009 Jun 02 7:53 AM
2009 Jun 02 8:31 AM
What's up with your issue here, solved?
Please don't start duplicate threads on the same topics.
Thomas
2009 Jun 02 1:01 PM
Thomas,
let me know if you have a solution for this??
Thanks
Chandra