‎2009 Jun 19 3:25 PM
Hi Gurus,
I have the following problem :
There are 2 internal tables namely 1 &2.
Now there is a field in table 1 'AUGBL' which should be equal to field in Table2-BELNR.
Now if there is a match between TABLE1-AUGBL and TABLE2-BELNR,
so we move to table 2 to look for 'augbl' associated with 'belnr' in the same table.
Then I have to give the following logic -
If table2-belnr = table2-augbr,
Then do nothing.
Else.
Check, for the Augbl which will equal Belnr in a different position in table 2.
For ex:
Table1-AUGBL = 2.
So now we have to search a field when Table1-augbl = Table2-belnr = 2.
Now for this record in table2, there are 2 conditions:
When Table2-augbl = 2, (in which case we do nothing)
or,
Table2-augbl NE 2, or Table2-augbl = 3.
In the latter case, there will be another field in Table2-BELNR = 3. So we go to this record now and check for the associated AUGBL and do the same checks above.
We keep on continuing for this till the time we do not get the Table2-belnr = Table2-augbl in the end for the same record.
Now I want to achieve this without using nested loop.
Kindly help as I already have wated a lot of time.
Please let me know if there are any clarifications.
‎2009 Jun 19 3:32 PM
Try to use Join in select query with common fields..
or send the query you used so we wil try to optimize and send the better solution..
‎2009 Jun 19 3:32 PM
Please see [The Performance of Nested Loops|/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops]
Rob
‎2009 Jun 19 3:41 PM
Hey..
Before u get the data into two internal tables through SELECT stmts.
U can use JOIN instead of two SELECT stmts ..that wud fetch the data into single internal table..
and that may ease ur validations and further process..
try this out..
Thanks and Regards,
KC
‎2009 Jun 19 3:57 PM
Hi,
Thanks for the reply but I do need both of the tables for some other reasons. I am not selecting data in them, but putting data in them based on certain restrictions.
‎2009 Jun 19 5:41 PM
This works
loop at itab into wa_itab1.
read table itab2 into wa_itab2 index sy-index / sy-tabix. " (optional: Binary search with sort )
if sy-subrc eq 0.
endif.
endloop.
‎2009 Jun 24 10:17 AM