‎2010 Feb 08 8:30 AM
Hello Experts, I Have to Tune a report But the problem Aries in this Nested loop.
it taking appox 10 min to exec,Bec of itab1 has 4000 rec and itab2 has 16000 records,
Is there Any Solution To Perform This.........
loop at itab1.
loop at itab2.
if itab1-matnr eq itab2-matnr .
itab2-kbetr = itab1-kbetr .
itab2-konwa = itab1-konwa .
endif.
modify itab2 .
endloop.
endloop.
*
Thanks.............................
‎2010 Feb 08 10:14 AM
now yolu should be able to answer your last question by yourself:
Most important you fast access in all operations inside a loop !!!
+ use the workaround with READ BINARY SEARCH ... LOOP as explained above
+ or better use a SORTED TABLE !!!
(the 10 points answer is wrong!)
Additionally use the ASSIGNING plus replace the MODIFY by a direct change of the field-symbol.
All explained, solves also your new problem ... and hoopefully also your future problems with internal tables!
‎2010 Feb 08 9:10 AM
Hi,
try like this:
field_symbols: <fs_itab2> like itab2.
loop at itab1.
loop at itab2 where matnr = itab1-matnr assigning <fs_itab2>.
<fs_itab2>-kbetr = itab1-kbetr .
<ifs_tab2>-konwa = itab1-konwa .
endloop.
endloop.
make sure itab2 is a SORTED table with key matnr.
use field symbols to avoid the modify.
hth,
Hermann
‎2010 Feb 08 9:12 AM
Hi,
try like this
Loop at itab2.
read table itab1 with key matnr = itab2-matnr.
if sy-subrc = 0.
itab2-kbetr = itab1-kbetr.
itab2-konwa = itab1-konwa.
modify itab2.
endif.
endloop.
‎2010 Feb 08 9:28 AM
Thanks Alot Experts.
Issue Has Been Resolved
Edited by: HEMANT_A1 on Feb 8, 2010 11:27 AM
‎2010 Feb 08 9:21 AM
Hi,
Another way which doesn't use sorted tables is the following :
FIELD-SYMBOLS : <fs_itab2> LIKE itab2.
SORT itab2 BY matnr.
LOOP AT itab1.
" Search the first matching entry
READ TABLE itab2 TRANSPORTING NO FIELDS
WHERE matnr = itab1-matnr
BINARY SEARCH.
IF sy-subrc = 0.
" Loop at all following entries
LOOP AT itab2 ASSIGNING <fs_itab2>
FROM sy-tabix.
" If entries does not match any more, exit
IF <fs_itab2>-matnr NE itab1-matnr.
EXIT.
ENDIF.
<fs_itab2>-kbetr = itab1-kbetr.
<fs_itab2>-konwa = itab1-konwa.
ENDLOOP. " AT itab2
ENDIF.
ENDLOOP. " AT itab1
There are 2 important rules : use field-symbols to modify internal tables and read only useful entries...
Best regards,
Samuel
‎2010 Feb 08 10:14 AM
now yolu should be able to answer your last question by yourself:
Most important you fast access in all operations inside a loop !!!
+ use the workaround with READ BINARY SEARCH ... LOOP as explained above
+ or better use a SORTED TABLE !!!
(the 10 points answer is wrong!)
Additionally use the ASSIGNING plus replace the MODIFY by a direct change of the field-symbol.
All explained, solves also your new problem ... and hoopefully also your future problems with internal tables!
‎2010 Feb 08 10:26 AM