‎2007 Apr 12 9:46 AM
HI Guys,
can i use loop at itab with read table stmt.
like:-
loop at itab.
read table itab index n.
............
.............
...............
endloop.
if yes then what will be the output of this stmt.
‎2007 Apr 12 9:52 AM
hi
you can ofcrse use read inside a loop.
but the scenario is like this -
both LOOP and READ are used for the similar purposes. LOOP is for multiple records, READ is for single record.
if you use READ statement inside the LOOP for same internal table, it is of no use. it is like you are doing the same operation two times.
in case of different internal tables say header and item, then it works and it has a purpose...
hope this info helps u.
thx
pavan
*pls mark all the helpful answers
‎2007 Apr 12 9:48 AM
Hi,
What's your purpose:
Loop at ITAb where...some condition you can use
or Loop At itab.
if <condition>
endif.
endloop.
within the same loop what's the use of read of the same internal table.
reward if sueful
regards,
ANJI
‎2007 Apr 12 9:49 AM
Hi,
Yes you can use read statement inside a loop.
LOOP AT gt_items INTO gs_items.
READ TABLE gt_header INTO gs_header INDEX gc_one_num.
IF sy-subrc EQ gc_zero_num.
gs_itab2-lifnr = gs_header-lifnr. " Transfers the data into final table work area
ENDIF.
endloop.
Regards
Kannaiah
‎2007 Apr 12 9:49 AM
yes u can use....
before using read inside loop you should know the condition to match both loop and read statement i.e by using common field name....
and the output depends on the condition
‎2007 Apr 12 9:50 AM
hi,
you can use..
See looping at ITAB first triggers to the first line of the internal table.
then you are reading it.. Whats is the need of doing like this?
Instead you can derectly red the table if you know the keys..
regards,
nazeer.
‎2007 Apr 12 9:51 AM
you can use this but what is your need i dont know it will not give any syntax error
loop at itab.
read table itab index n.
<here you will get the value of read table statement in itab header line>.
.............
...............
endloop.
regards
shiba dutta
‎2007 Apr 12 9:52 AM
‎2007 Apr 12 9:52 AM
Hi,
yes you can use read statement inside loop.
But if you are trying to modify the table the better use it with assigning statement..
becoz of performance reasons..
reward points if helpful.
regards,
santosh
‎2007 Apr 12 9:52 AM
hi
you can ofcrse use read inside a loop.
but the scenario is like this -
both LOOP and READ are used for the similar purposes. LOOP is for multiple records, READ is for single record.
if you use READ statement inside the LOOP for same internal table, it is of no use. it is like you are doing the same operation two times.
in case of different internal tables say header and item, then it works and it has a purpose...
hope this info helps u.
thx
pavan
*pls mark all the helpful answers