‎2011 Jan 06 6:26 AM
Hi,
For Performance optimization I added READ with BINARY SEARCH instead SQL Query this part is working better.. But replacing SQL with LOOP ENDLOOP. is making the performance worse..
Below is the code for LOOP:
LOOP AT IT_OPS_BOM WHERE slot EQ zslot
AND zsku(11) EQ tmp_opsbom-zsku(11)
AND ZCOMP = ' '.
*Do some logic
ENDLOOP.
Can we do someting to Furthur optimize the LOOP.. ENDLOOP.. part?
No. of Records in IT_OPS_BOM is more than 2 Lac.
Thanks,
Preyansh
‎2011 Jan 06 7:09 AM
Hi Preyansh ,
If you want a loop..where...endloop structure to be optimized, explore the following possibilities:
1. Check if this table can be made as sorted with zslot, zsku, zcomp as the key. The condition here is that the table is initialized once and has little or no inserts.
2. sort the table by zslot, zsku, zcomp.
read table ...with key .... binary search.
if sy-subrc = 0.
l_index = sy-tabix.
endif.
loop at table from l_index.
if <zslot zsku zcomp> changing from the initial one, exit. endif.
.....
endloop.
Also, check if the offset in the where condition can be removed.
Hope this helps.
Regards
Hema
‎2011 Jan 06 7:09 AM
Hi Preyansh ,
If you want a loop..where...endloop structure to be optimized, explore the following possibilities:
1. Check if this table can be made as sorted with zslot, zsku, zcomp as the key. The condition here is that the table is initialized once and has little or no inserts.
2. sort the table by zslot, zsku, zcomp.
read table ...with key .... binary search.
if sy-subrc = 0.
l_index = sy-tabix.
endif.
loop at table from l_index.
if <zslot zsku zcomp> changing from the initial one, exit. endif.
.....
endloop.
Also, check if the offset in the where condition can be removed.
Hope this helps.
Regards
Hema
‎2011 Jan 06 11:26 AM
Answered.
Thanks Hema.
Reply gave a good idea for implementing the optimization.
Regards,
Preyansh
Edited by: DWIVEDP on Jan 6, 2011 4:56 PM
‎2011 Jan 06 9:33 PM
Hi guys,
As your intention is restrict by these 3 fields and one of than is partial content I don't think the sort will help you a lot.
It's better to you have a new field zsku11 with this part first:
something like (my doubt here is if this overhead will have provide a effective solution as there's an implicit index reorganization):
LOOP AT IT_OPS_BOM ASSIGNING <fs_it_ops>.
<fs_it_ops>-zsku11 = <fs_it_ops>-zsku(11).
ENDLOOP.The table IT_OPS_BOM should be a sorted table by slot, zsku11 and zcomp.
So the LOOP will be optimized internally needing no special handling, you coding should be:
LOOP AT IT_OPS_BOM WHERE slot EQ zslot
AND zsku11 EQ tmp_opsbom-zsku(11)
AND ZCOMP = ' '.
*Do some logic
ENDLOOP.Make sense you do this initial loop?
Is there another way to deal with this partial zsku? Maybe change the order to slot, zcomp and zsku with original suggestion sent by Hema should provide a good support.
Regards, Fernando Da Ros
‎2011 Jan 07 4:21 AM
I totally agree with you, Ros. This is what I meant by
Also, check if the offset in the where condition can be removed.
Thanks,
Hema
‎2011 Jan 07 11:44 AM
Hi Fernando,
It really made sence to optimize in described way.. my program is running much faster... Per feedback it got improved by 4 % extra. (My Other optimization brang the runtime by 35% less and now it is 39% lesser).
Thanks to Hema too. Her advice (2nd point which I understood) also brang 3% furthur optimization.. 32% to 35%)
Regards,
Preyansh
‎2011 Jan 07 12:21 PM
Hi Preyansh,
In fact Hema's and mine suggestions are the same in essence but different implementation.
Anyway, did you also tried to define the table as sorted on declaration?
If you did this you don't need the READ BINARY and the IF EXIT sequence inside the LOOP.
Regards, Fernando Da Ró
‎2011 Jan 10 6:35 AM
Hi Fernando,
No I didn't try with Sorted Table. Since I am reading the internal table with 3 Different combination at three places.
I am keeping the Interna table as standard table and SORTing it at 3 places with different fields.
Thanks,
Preyansh