<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to Optimize LOOP statement. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543090#M1562591</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answered.&lt;/P&gt;&lt;P&gt;Thanks Hema.&lt;/P&gt;&lt;P&gt;Reply gave a good idea for implementing the optimization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Preyansh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: DWIVEDP on Jan 6, 2011 4:56 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Jan 2011 11:26:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-01-06T11:26:27Z</dc:date>
    <item>
      <title>Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543088#M1562589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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..&lt;/P&gt;&lt;P&gt;Below is the code for LOOP:&lt;/P&gt;&lt;P&gt;LOOP AT IT_OPS_BOM WHERE slot EQ zslot&lt;/P&gt;&lt;P&gt;                                                 AND zsku(11) EQ tmp_opsbom-zsku(11)&lt;/P&gt;&lt;P&gt;                                                 AND ZCOMP = ' '.&lt;/P&gt;&lt;P&gt;*Do some logic&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can we do someting to Furthur optimize the LOOP..  ENDLOOP.. part?&lt;/P&gt;&lt;P&gt;No. of Records in IT_OPS_BOM is more than 2 Lac.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Preyansh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 06:26:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543088#M1562589</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-06T06:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543089#M1562590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Preyansh ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want a loop..where...endloop structure to be optimized, explore the following possibilities:&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;2. sort the table by zslot, zsku, zcomp.  &lt;/P&gt;&lt;P&gt;    read table ...with key .... binary search.&lt;/P&gt;&lt;P&gt;   if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      l_index = sy-tabix.&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;P&gt;    loop at table from l_index.&lt;/P&gt;&lt;P&gt;    if &amp;lt;zslot zsku zcomp&amp;gt; changing from the initial one, exit. endif.&lt;/P&gt;&lt;P&gt;    .....   &lt;/P&gt;&lt;P&gt;    endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, check if the offset in the where condition can be removed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hema&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 07:09:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543089#M1562590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-06T07:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543090#M1562591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answered.&lt;/P&gt;&lt;P&gt;Thanks Hema.&lt;/P&gt;&lt;P&gt;Reply gave a good idea for implementing the optimization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Preyansh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: DWIVEDP on Jan 6, 2011 4:56 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 11:26:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543090#M1562591</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-06T11:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543091#M1562592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;It's better to you have a new field zsku11 with this part first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;something like (my doubt here is if this overhead will have provide a effective solution as there's an implicit index reorganization):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT IT_OPS_BOM ASSIGNING &amp;lt;fs_it_ops&amp;gt;.
  &amp;lt;fs_it_ops&amp;gt;-zsku11 = &amp;lt;fs_it_ops&amp;gt;-zsku(11).
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table IT_OPS_BOM should be a sorted table by slot, zsku11 and zcomp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the LOOP will be optimized internally needing no special handling, you coding should be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT IT_OPS_BOM WHERE slot EQ zslot
AND zsku11 EQ tmp_opsbom-zsku(11)
AND ZCOMP = ' '.
*Do some logic
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sense you do this initial loop?&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Fernando Da Ros&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 21:33:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543091#M1562592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-06T21:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543092#M1562593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I totally agree with you, Ros. This is what I meant by&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; Also, check if the offset in the where condition can be removed. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hema&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 04:21:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543092#M1562593</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-07T04:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543093#M1562594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fernando,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to Hema too. Her advice (2nd point which I understood) also brang 3% furthur optimization.. 32% to 35%)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Preyansh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 11:44:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543093#M1562594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-07T11:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543094#M1562595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Preyansh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact Hema's and mine suggestions are the same in essence but different implementation.&lt;/P&gt;&lt;P&gt;Anyway, did you also tried to define the table as sorted on declaration?&lt;/P&gt;&lt;P&gt;If you did this you don't need the READ BINARY and the IF EXIT sequence inside the LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Fernando Da Ró&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 12:21:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543094#M1562595</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-07T12:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Optimize LOOP statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543095#M1562596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fernando,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No I didn't  try with Sorted Table. Since I am reading the internal table with 3 Different combination at three places.&lt;/P&gt;&lt;P&gt;I am keeping the Interna table as standard table and SORTing it at 3 places with different fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Preyansh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2011 06:35:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-optimize-loop-statement/m-p/7543095#M1562596</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-10T06:35:02Z</dc:date>
    </item>
  </channel>
</rss>

