‎2007 Jun 22 11:12 PM
Hi
Can I know that is there any other way, to avoid using Loop inside a Loop?
Thanks
‎2007 Jun 22 11:14 PM
u can use the read statement instead of multiple loops... thats the one good solution
‎2007 Jun 22 11:19 PM
The second table has more than one similar record so I cant use a READ inside the first Loop.
Any way I can avoid using Loop inside the Loop ?
‎2007 Jun 22 11:21 PM
Use the read statement and give the condition what differentiates one similar record from the other
‎2007 Jun 22 11:32 PM
ok,,let me explain a bit more..
Say my first internal table as coulmns as material number and plant
And my second internal table as materail numbers and it corresponding characteristics ie. one material number has more than one characteristics.
So I cant read on second internal table with key only as material number (which is known to me) ie, In this case I need to do a Loop inside a Loop to check for every characteristic for a material.
And I want to avoid doing that.
I hope I am clear to you.
‎2007 Jun 22 11:34 PM
I think there's no other option rather than using LOOP inside LOOP here.
To make it more effective you can use:
LOOP AT ITAB1.
LOOP AT ITAB2 WHERE MATNR = ITAB1-MATNR.
....
ENDLOOP.
ENDLOOP.
Second option would be to join these 2 tables on Material Number and get data into single internal table:
SELECT * INTO ITAB
FROM TABLE1 INNER JOIN TABLE 2
ON TABLE1MATNR = TABLE2MATNR.
Reward points if useful.
‎2007 Jun 22 11:39 PM
In that case u have to use the loop inside the loop two loops does not make that much difference in performance if u have more than two loops that makes the difference i guess....
‎2007 Jun 22 11:44 PM
What if there are more than 2 loops,,how can we handle it?
I think I need to do that also later in my program.
Thanks
‎2007 Jun 22 11:56 PM
Hi,
May be this way.
loop at i_mara.
do.
read table i_mara_characteristics wuth key matnr = i_mara-matnr.
if sy-subrc eq 0.
<<< whatever you want to do >>>
delete i_mara_characteristics index sy-tabix.
else.
exit.
endif.
enddo.
endloop.
aRs
‎2010 Dec 31 2:19 PM