12-15-2008 9:15 AM
Hi ,
I have written some update FM.I am doing this based on the records(1 to many) in the table parameter.
The requirement is,during the updation if any error happens,I need to rollback the work and need to stop the further processing.As of now,it is roll backing the work.
But it is going to the next line.I have used 'EXIT' statement in my pgm.
Please suggest me a solution.
Thanx,
Selva
Edited by: Julius Bussche on Dec 15, 2008 11:04 AM
12-15-2008 9:33 AM
Hi,
Let us assume there is a header and an Item table and that the header table is the check table for the item table.
So
lt_header type standard table of header_table,
lt_item type standard table of item_table.
Assume all data is in and you are ready for updation.
insert header_table from tablelt_header.
if sy-subrc eq 0.
insert item_table from lt_item.
if sy-subrc eq 0.
commit work and wait.
else.
rollback work.
perform issue_error_message_to_user.
else.
perform issue_error_message_to_user.
endif.
I have written this code in this reply only. Please use proper syntax as required. I just shared the concept i had in mind.Please Check and tell
12-15-2008 9:16 AM
12-15-2008 9:18 AM
check sy-subrc and do a proper handling of the codes youre getting back. I case of error use ROLLBACK.
12-15-2008 9:32 AM
A lot depends on where you have used the 'EXIT' command.
The code should process the next line. It could be that 'EXIT' is exiting some loop itself of processing.
If inside a loop instead of EXIT consider CONTINUE in case you want rollback and dont want to process anything else in the loop.
12-15-2008 9:33 AM
Hi,
Let us assume there is a header and an Item table and that the header table is the check table for the item table.
So
lt_header type standard table of header_table,
lt_item type standard table of item_table.
Assume all data is in and you are ready for updation.
insert header_table from tablelt_header.
if sy-subrc eq 0.
insert item_table from lt_item.
if sy-subrc eq 0.
commit work and wait.
else.
rollback work.
perform issue_error_message_to_user.
else.
perform issue_error_message_to_user.
endif.
I have written this code in this reply only. Please use proper syntax as required. I just shared the concept i had in mind.Please Check and tell