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

reports

Former Member
0 Likes
778

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
760

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

8 REPLIES 8
Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

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.

Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

yes u can do that

Read only

0 Likes
760

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

Read only

Former Member
0 Likes
761

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