10-08-2008 10:32 AM
how can we loop a table with respect to the index values of the table i want to loop the table upto an index 5 how can i do it.
thanks in advance
10-08-2008 10:34 AM
Hi
Loop at table into fieldstring.
your code
if sy-index eq 5.
exit.
endif.
endloop.
10-08-2008 10:34 AM
Hi
Loop at table into fieldstring.
your code
if sy-index eq 5.
exit.
endif.
endloop.
10-08-2008 10:34 AM
loop at git_itab from 1 to 5.
endloop
or
loop at git_itab to 5.
endloop
Edited by: Amit Gupta on Oct 8, 2008 11:40 AM
10-08-2008 10:37 AM
.. LOOP AT inttab
INTO wa_inttab
WHERE table_line < 5 .
{... }
ENDLOOP. .
10-08-2008 10:39 AM
>
>
.. LOOP AT inttab > INTO wa_inttab > WHERE table_line < 5 . > {... } > ENDLOOP. .
Are you sure this is going to work?
10-08-2008 10:38 AM
hi abhinay,
LOOP AT <itab> [INTO <wa>]
[FROM <n1>] [TO <n2>]
[WHERE <condition>].
where n1 and n2 are index.
hope it may help u.
thanks
Sachin
10-08-2008 10:50 AM
hi
Sample Code:
READ TABLE T_MARC1 INTO WA_MARC WITH KEY WERKS = P_WERKS.
IF SY-SUBRC EQ 0.
L_TABIX = SY-TABIX + 1.
ADD 1 TO COUNT.
LOOP AT T_MARC1 INTO WA_MARC FROM L_TABIX.
IF WA_MARC-WERKS NE P_WERKS.
EXIT.
ENDIF.
ADD 1 TO COUNT.
ENDLOOP.
ENDIF.
If you look at the above code, first we read the record which appears first in the list of records, hence the index of that entry is stored in a local variable, further records can be read using index from loop which is very fast in access.
regards
Satish
10-08-2008 11:13 AM
Hi Abhinay,
Try this code :
Loop at itab into wa.
if sy-tabix eq 5.
exit.
else.
<paste your code here>
endif.
endloop.
This will solve.
Regards,
Swapna.