Application Development 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: 

nested loop using two dynamic tables

Former Member
0 Kudos

Hi all,

i'm trying to create a nested loop with two dynamic tables.

However, i cannot yet.

for example;

<table1> has two fields : kunnr and menge, then

<table2> has three fields : kunnr, matnr and menge.

The field kunnr is key field for those two tables.

and the loop will seem like below :

loop at <table1> assigning <line1>.

....loop at <table2> assigning <line2> [where kunnr = <table1>kunnr].

......bla... bla.. bla...

....endloop.

endloop.

However, i could not handle to use this where condition.

Any solution offered will be appreciated.

Thnkx....

2 REPLIES 2

Former Member
0 Kudos

Hi

U can't use the condition in this situation, so u need read all records of second table and check if the condition is sutisfated:

FIELD-SYMBOLS: <KUNNR1> TYPE ANY,
                            <KUNNR2> TYPE ANY.

LOOP AT <TABLE1> ASSIGNING <LINE1>.

   ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <LINE1> TO <KUNNR1>.

  LOOP AT <TABLE2> ASSIGNING <LINE2>.
      ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <LINE2> TO <KUNNR2>.
      
      CHECK <KUNNR1> = <KUNNR2>.
  
      BLA BLA BLA
   ENDLOOP.
ENDLOOP.

Max

Former Member
0 Kudos

so i did not use the nested loop. thanks