<?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 LOOP and Performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049133#M1352070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 Internal Tables..&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;itab1 containgi 2000 employees numbers.&lt;/P&gt;&lt;P&gt;itab2 containing 5000 employees numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The requirement is to delete the employees from itab2 if the itab2-pernr = itab1-pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the following logic...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;if itab1-pernr = itab2-pernr.&lt;/P&gt;&lt;P&gt;delete itab2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the performance of the report is becoming issue with this logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other logic where the processing will become faster than the current one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Moved to the correct forum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Aug 13, 2009 9:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Aug 2009 10:44:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-13T10:44:51Z</dc:date>
    <item>
      <title>LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049133#M1352070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 Internal Tables..&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;itab1 containgi 2000 employees numbers.&lt;/P&gt;&lt;P&gt;itab2 containing 5000 employees numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The requirement is to delete the employees from itab2 if the itab2-pernr = itab1-pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the following logic...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;if itab1-pernr = itab2-pernr.&lt;/P&gt;&lt;P&gt;delete itab2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the performance of the report is becoming issue with this logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other logic where the processing will become faster than the current one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Moved to the correct forum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Aug 13, 2009 9:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:44:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049133#M1352070</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049134#M1352071</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;sort itab2 by pernr.&lt;/P&gt;&lt;P&gt;Loop at Itab1.&lt;/P&gt;&lt;P&gt;delete itab2 where pernr = itab1-pernr.&lt;/P&gt;&lt;P&gt;enloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kiran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:47:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049134#M1352071</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049135#M1352072</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;Use following logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;read itab1 into wa_tab1 where pernr = itab2-pernr.&lt;/P&gt;&lt;P&gt;if sy-subrc is initial.&lt;/P&gt;&lt;P&gt;delete itab2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Milan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:48:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049135#M1352072</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049136#M1352073</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;Why don't use a where condition?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab1.
  loop at itab2 where pernr = itab1-pernr-.
     delete itab2..
   endloop.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab1.
  delete itab2 where pernr = itab1-pernr.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should improve the performamce, if you don't use a WHERE condition the system LOOP all record of ITAB2 for every record of ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:49:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049136#M1352073</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049137#M1352074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at itab2 into wa_tab2.&lt;/P&gt;&lt;P&gt;read table itab1 into wa_itab1 with key pernr = wa_itab2-pernr.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;delete from itab2 acc to ur req.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or use a where coditon at the LOOP statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:50:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049137#M1352074</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049138#M1352075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Define one more field in itab2 say flag. do not use delete in loop; set flag instead as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;loop at itab2.&lt;/P&gt;&lt;P&gt;if itab1-pernr = itab2-pernr.&lt;/P&gt;&lt;P&gt;set flag  = 'x' .&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete itab2 out side loop as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete itab2 where flag is 'X'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete in the loop cause performance issue bcoz every time record is deleted, system has to assign new index to all entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:51:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049138#M1352075</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T10:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049139#M1352076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at itab1 into wa1----&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;gt;use Work area &lt;/P&gt;&lt;P&gt;(loop at itab2) -&lt;/P&gt;&lt;HR originaltext="---------" /&gt;&lt;P&gt;&amp;gt;use read statement  READ itab2 into wa2 where itab2-pernr = wa1-pernr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this link once.&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3aef358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3aef358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 10:53:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049139#M1352076</guid>
      <dc:creator>former_member209217</dc:creator>
      <dc:date>2009-08-13T10:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP and Performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049140#M1352077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="18" __jive_macro_name="size"&gt;No, no, and no&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This question is NOT answered!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only the sorted table works optgimized with DELETE WHERE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The standard table needs sorting but also BINARY SEARCH, LOOP FROM and CHECK!!!!!&lt;/P&gt;&lt;P&gt;see  &lt;/P&gt;&lt;P&gt;Measurements on internal tables: Reads and Loops:&lt;/P&gt;&lt;P&gt;/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="18" __jive_macro_name="size"&gt;But&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would always recommend the opposite logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT itab2  ASSIGNING &amp;lt;fs&amp;gt;.
   READ TABLE itab1 TRANSPORTING NO FIELDS
             WITH KEY..:
* sort table, hash table or standard with binary search
   IF ( sy-subrc = 0 ).
   ELSE.
     APPEND &amp;lt;fs&amp;gt;  TO itab3.
   ENDIF.
ENDLOOP.

REFRESH itab2.
itab2[] = itab3[].
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is much safer and also fast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 15:20:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-and-performance/m-p/6049140#M1352077</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-13T15:20:03Z</dc:date>
    </item>
  </channel>
</rss>

