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

Different ways to loop at internal table..

Former Member
0 Likes
4,112

Hello Gurus,

What are the different ways to loop at a internal table...I mean if I have to two internal tables then how will i loop

Cheers:Jim

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,589

Hi Jimmy,

There is only one way of looping at internal table. More the number of internal table nested it becomes.

EX:

Loop at itab.

Loop at jtab.

Loop at ktab.

.......

EndLoop.

EndLoop.

EndLoop.

Regards,

Younus

<b>Reward Helpful Answers:-)</b>

Hello Gurus,

What are the different ways to loop at a internal table...I mean if I have to two internal tables then how will i loop

Cheers:Jim

7 REPLIES 7
Read only

Former Member
0 Likes
1,589

Hi,

U can use the Loop based on ur Requirement.If there is no relationship between those two Internal Tables,then u can write Seperate Loop Statements.If it is related then u can Write Nested Loops.

Regards,

Padmam.

Read only

Former Member
0 Likes
1,590

Hi Jimmy,

There is only one way of looping at internal table. More the number of internal table nested it becomes.

EX:

Loop at itab.

Loop at jtab.

Loop at ktab.

.......

EndLoop.

EndLoop.

EndLoop.

Regards,

Younus

<b>Reward Helpful Answers:-)</b>

Read only

Former Member
0 Likes
1,589

HI,

you can do like this

loop at itab1.

read table itab2 with key field = itab1-field binary search

or read table itab2 index sy-index.

endloop.

reward points if helpful,

regards,

venkatesh

Read only

S0025444845
Active Participant
0 Likes
1,589

Hi.

If u have two tables than

loop at one table into work area and then read second table.like this.

loop at itab1 into wa_itab1.

read table itab2 into wa_itab2

with key < common field in both tables.

append to final table.

clear wa_itab1,wa_itab2.

endloop.

regards,

sudha.

points if useful.

Read only

Former Member
0 Likes
1,589

Hi jimmy,

If you have two internal tables,

you can loop one table and read another table inside the loop.

eg.

loop at it_ekko into w_ekko.

read table it_ekpo into w_ekpo

with key ebeln = w_ekko-ebeln

binary search.

endloop.

regards,

Ruchika

Read only

amol_chaudhari5
Explorer
0 Likes
1,589

Hello Jim,

If the tables are related by some fileds,

then you can loop at one while for other table you can put where caluse

on filed to improve performance.

This is demo , both tables must be sorted by vbeln..

Loop at it_vbrk assigning <fs_vbrk>.

loop at it_vbrp assigning <fs_vbrp> where vbeln = <fs_vbrk>-vbeln.

.....

Regards,

Amol C.

*-- Award points if helpful..

Read only

Former Member
0 Likes
1,589

hi,

loop at itab1.

read table itab2 with key field = itab1-field binary search

or

read table itab2 index sy-index.

endloop.

loop at itab1 where itab1-fld = 'fldname'.

read table itab2 with key field = itab1-field binary search

or

read table itab2 index sy-index.

endloop.

reward points if helpful,

regards,

suresh