Application Development 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: 

Failed update is doing rollback, but not exiting.

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

krishnannarayanan_nampoot
Active Participant
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

if sy-subrc NE 0.

stop.

Endif.

rainer_hbenthal
Active Contributor
0 Kudos

check sy-subrc and do a proper handling of the codes youre getting back. I case of error use ROLLBACK.

Former Member
0 Kudos

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.

krishnannarayanan_nampoot
Active Participant
0 Kudos

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