12-18-2006 3:46 AM
HII FRNDS
CAN I RESTRICT A LOOP BEING PROCESED TO A LIMITED NO OF TIMES. IF YES THN HOW . I AM TRYIGN OUT WITH TABIX BUT ITS NOT WORKING CAN ANYBODY TELL ME ANY OTHER ALTERNATICES ..
THANX
ROHIT
12-18-2006 3:51 AM
You can have a counter, increment it manually and then exit depending on your condition.
Regards,
Ravi
12-18-2006 3:51 AM
You can have a counter, increment it manually and then exit depending on your condition.
Regards,
Ravi
12-18-2006 3:55 AM
YA BUT HOW SHOULD I CATCH THE NO OF TIMES MY LOOP HAS BEEN PROCESSED ..
12-18-2006 3:58 AM
DATA : COUNTER TYPE I.
LOOP AT ITAB.
Process the data
COUNTER = COUNTER + 1. " This will tell you how many times the loop has been processed.
IF COUNTER = your number.
exit.
ENDIF.
ENDLOOP.
If your number is bigger the number of entries in the internal table, it will come out once it processes all the entries.
Regards,
Ravi
Note - Please mark all the helpful answers
12-18-2006 3:56 AM
hi ,
try this
data count type i value 0.
loop at i tab into wa.
count = count + 1.
if count = 10.
exit.
endif.
endloop.
12-18-2006 3:59 AM
Hi Rohit ,
You can very well do it. Here is a sample code for the same
Data : Begin of it_1 occurs 0 ,
test type i,
End of it_1.
Data : v_temp type i.
start-of-selection.
clear v_temp.
while v_temp < 10.
v_temp = v_temp + 1.
it_1-test = v_temp.
append it_1.
endwhile.
clear v_temp.
loop at it_1.
if sy-tabix < 5.
write it_1-test.
else.
exit.
endif.
endloop.
Regards
Arun
12-18-2006 4:00 AM
you can use
do n times.
enddo.
where n is your defined number.
or <b>loop at itab</b>.
if sy-tabix = n.
exit.
endif.
endloop.
or data : counter type i.
loop.
counter = counter + 1.
if counter = n.
exit.
endif.
endloop.
regards
shiba dutta
12-18-2006 4:02 AM
Hi,
This is executable sample code .
Data: lv_tabix type sy-tabix,
itab type table of spfli,
wa type spfli.
Select * from spfli into table itab.
Check sy-subrc = 0.
Loop at itab into wa.
lv_tabix = sy-tabix.
if lv_tabix > 4.
exit.
endif.
write lv_tabix.
Endloop.