2010 Sep 26 6:39 AM
Dear All ,
I am using below code in my prg..
loop at itab.
loop at itab1 where matnr = itab-matnr.
endloop.
endloop.
IN this code itab is having only 1 row for particular matnr and in itab1 is having multiple row for particular matnr. and i am facing here performance issue . it is taking so much time. Because for particular matnr , program have to search matnr in whole itab1. so is there any code line i have to use so it can search directly matnr from itab1 and dont need to search whole table.... because here if itab is having m row and itab1 is having n row , than looping is happened mn times..
so , how can i reduce it ? please anybody know , than please help me for same...
Thank You ,
2010 Sep 27 7:08 AM
Hi,
loop at itab.
loop at itab1 where matnr = itab-matnr.
endloop.
endloop.
itab1 is having multiple row for particular matnr
define tab1 table as sorted table with non-unieque key matnr.
and also used the field-symbols instead of work area.
loop at itab Assigning <fs_itab>.
loop at itab1 assigning <fs_itab1> where matnr = <fs_itab>-matnr.
endloop.
endloop.
Define
field-symboles <fs_itab> has type of itab table type.
<fs_itab1> has type of itab1 table type.
It will give better performance, Don't used the parallel cursor technique.
Try it it will resolve your problem
Hi,
loop at itab.
loop at itab1 where matnr = itab-matnr.
endloop.
endloop.
itab1 is having multiple row for particular matnr
define tab1 table as sorted table with non-unieque key matnr.
and also used the field-symbols instead of work area.
loop at itab Assigning <fs_itab>.
loop at itab1 assigning <fs_itab1> where matnr = <fs_itab>-matnr.
endloop.
endloop.
Define
field-symboles <fs_itab> has type of itab table type.
<fs_itab1> has type of itab1 table type.
It will give better performance, Don't used the parallel cursor technique.
Try it it will resolve your problem
2010 Sep 26 9:32 AM
Hello
You should definitely have a look at the MUST read blog written by Rob Burbank:
[JOINS vs. FOR ALL ENTRIES - Which Performs Better?|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6050] [original link is broken] [original link is broken] [original link is broken];
Regards
Uwe
2010 Sep 26 10:37 AM
hi,
u can use parallel cursor technique to improve performance .
sample code is like :
sort: lt_vbpa by kunnr, "Sorting by key is very important
lt_kna1 by kunnr. "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1 " This sets the sy-tabix
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0. "Does not enter the inner loop
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop
exit.
endif.
Your Actual logic within inner loop ******
endloop. "KNA1 Loop
endif.
endloop. " VBPA Loop
Regards,
Sarang
2010 Sep 27 6:35 AM
Hi Sarang
Thanks to give me sample code of parallel cursor technique..
Can u just what is meaning of binary search ? how it works ?
And here in your secong loop
loop at lt_kna1 into wa_kna1 from v_kna1_index.
if lt_konv is having multiples row for particular Kunnr.. than its read only 1 time than how it works ?
2010 Sep 27 1:19 PM
Can u just what is meaning of binary search ? how it works ?
Please understand binary search,sorted tables etc before getting into the coding
Hi,
You can search the documentations and read how the sorted tables work .
Let me explain how binary search works
consider the below entries in your internal table. You must
sort the internal table before doing a binary search.
You will know the importance of sorting when you understand the functionality.
This is just a rough explanation.Suppose you want to get the record
which holds the value 10, when you use a binary search.
the contents are divided into two segements like
1
2
6
7
***
9
10
13
17
18
It takes the left segement and does a left traversal, if the value is found its
returned else it takes the right segement and again divides it
like
9
10
***
13
17
18
It again does the same left traversal, here the data is found.it stops and exits.
Experts correct me if im wrong
2010 Sep 28 5:44 AM
2010 Sep 26 4:25 PM
Data:itab1 type sorted table of type1 with non-unique key matnr.
Just declare your matnr as above and use the same nested loop.
2010 Sep 27 6:29 AM
Hi ,
Keshav , thanks for reply...in your declaration what is meaning of type1.. And how it works can u explain in brief ?....
2010 Sep 27 7:08 AM
Hi,
loop at itab.
loop at itab1 where matnr = itab-matnr.
endloop.
endloop.
itab1 is having multiple row for particular matnr
define tab1 table as sorted table with non-unieque key matnr.
and also used the field-symbols instead of work area.
loop at itab Assigning <fs_itab>.
loop at itab1 assigning <fs_itab1> where matnr = <fs_itab>-matnr.
endloop.
endloop.
Define
field-symboles <fs_itab> has type of itab table type.
<fs_itab1> has type of itab1 table type.
It will give better performance, Don't used the parallel cursor technique.
Try it it will resolve your problem
2010 Sep 27 7:28 AM
Hi Ravishankar,
Thanks for ur help.. Its really works and easy than another method.......
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |