‎2009 Jan 19 6:21 AM
This is my code
-
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
exit.
endloop.
Loop at itab3 -
>loop 2
endloop
-
Now I want that when whenever sy-subrc = 4 in loop 1... the exit should exit the whole block ie loop 2 also...But with my above code it is exiting only the first loop but passing thorught loop 2.
How should I solve my purpose...( Using continue is not helping either)
‎2009 Jan 19 6:24 AM
data : l_flag type c.
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
l_flag = 'X'.
exit.
endloop.
if l_flag is initial.
Loop at itab3 ---->loop 2
{ exp
}
endloop.
endif.
clear l_flag.Best regards,
Prashant
‎2009 Jan 19 6:24 AM
data : l_flag type c.
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
l_flag = 'X'.
exit.
endloop.
if l_flag is initial.
Loop at itab3 ---->loop 2
{ exp
}
endloop.
endif.
clear l_flag.Best regards,
Prashant
‎2009 Jan 19 6:27 AM
Hi Priya,
Try this way.
data: flag type c.
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
flag = 'X'.
exit.
endloop.
Loop at itab3 -
>loop 2
{ IF flag = 'X'.
exit.
ENDIF.
}
endloop
c
‎2009 Jan 19 6:28 AM
Hi,
then, you can check the subrc while doing the second loop.
eg:
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
exit.
endloop.
IF sy-subrc EQ 0.
Loop at itab3 -
>loop 2
endloop
endif.
Hope it helps!!
Regards,
Pavan
‎2009 Jan 19 4:30 PM
>
> loop at itab. ---> loop 1
> read table itab2 with key id = itab-id.
> if sy-subrc = 4.
> exit.
> endloop.
>
> IF sy-subrc EQ 0.
> Loop at itab3 -
>loop 2
> endloop
> endif.
Pavan - SY-SUBRC will depend on whether or not there are entries in itab, not the READ TABLE itab2 statement.
Rob
‎2009 Jan 19 6:30 AM
Hi
If ITAB3 is having relationship with either ITAB1 or ITAB2 then
loop at itab. ---> loop 1
read table itab2 with key id = itab-id.
if sy-subrc = 4.
exit.
else.
read table itab3 with key id = itab-id. or read table itab3 with key id = itab2-id.
if sy-subrc = 0.
*Exp
endif.
endif.
endloop.
The above code will improve the performance.
Regards
Shiva