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

skip error record within loop

Former Member
0 Likes
1,956

Hi all,

How to skip error records within loop.

Regards,

bala

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,373

Hi,

You can use CONTINUE Statement .

Loop at it_tab.

IF errorvalue " check for error records

CONTINUE . "This will skip the rest of the code and

continue with next pass of the loop.

ELSE

" Write the rest of the code"

Endif

ENDLoop

Regards

Beena

6 REPLIES 6
Read only

naimesh_patel
Active Contributor
0 Likes
1,373

If you have msgtyp in your table, then

Loop at itab where msgtyp <> 'E'.

endloop.

Regards,

Naimesh

Message was edited by: Naimesh Patel

Read only

Former Member
0 Likes
1,373

Hi krithika,

1. we can use this logic

2. Loop at itab.

check field1 = 'wrong value'

check field3 = 'wrong value'

*----


*--- OTHER GOOD CODE

ENDLOOP.

regards,

amit m.

Read only

Former Member
0 Likes
1,373
loop at itab.

  if itab-value = wrong.
  else.
   * write ur code here.
  endif.
endloop.
Read only

Former Member
0 Likes
1,373

Hi,

For wg.

loop at itab.

if err = 'x'.

skip.

else.

continue.

endif.

endloop.

skip can't use within loop.

what's the alternative?

Regards,

bala.

Read only

Former Member
0 Likes
1,374

Hi,

You can use CONTINUE Statement .

Loop at it_tab.

IF errorvalue " check for error records

CONTINUE . "This will skip the rest of the code and

continue with next pass of the loop.

ELSE

" Write the rest of the code"

Endif

ENDLoop

Regards

Beena

Read only

aris_hidalgo
Contributor
0 Likes
1,373

Hi,

You can comment out codes that looks/functions like the one below:

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Also, the type 'E' for msgtype means that it is an error.

Hope this helps...

P.S. Please award points for useful answers.