<?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: Slow Performance i.e. pimping up an internal table loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087959#M1971548</link>
    <description>&lt;P&gt;You need to work with sorted tables both with the same ID. You are going to see an incredible improvement in performance. Do not work never with this king of declaration like TYPE STANDARD TABLE for this king of development.&lt;/P&gt;&lt;P&gt;I imagine that you are working without HANA database. If you have HANA you can model a CDS view preparing the data.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2019 08:20:41 GMT</pubDate>
    <dc:creator>ruben_rollano</dc:creator>
    <dc:date>2019-09-12T08:20:41Z</dc:date>
    <item>
      <title>Slow Performance i.e. pimping up an internal table loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087957#M1971546</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
  &lt;P&gt;I am struggling with a quite simple loop, that is weirdly slow. I was wondering if maybe you can give me a helping hand on this subject.&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;So, I have 2 selects into internal tables, that are fast ( approx. 1 sec for both select), e.g. &lt;EM&gt;lt_a&lt;/EM&gt; and &lt;EM&gt;lt_b&lt;/EM&gt;, where &lt;EM&gt;lt_a&lt;/EM&gt; has a sub-table where the corresponding &lt;EM&gt;lt_b&lt;/EM&gt; rows should go (connected by an identifier &lt;EM&gt;id&lt;/EM&gt; ). So - here's my loop:&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;*Note: some number and performance information:&lt;BR /&gt; lt_a (6 columns) - approx 55 000 rows&lt;BR /&gt; lt_b (4 columns) - approx 40 000 rows&lt;BR /&gt; time: ~45 seconds (!)&lt;/P&gt;
  &lt;P&gt;Is there something I could enhance? Should I use &lt;EM&gt;corresponding &lt;/EM&gt;or go with the &lt;EM&gt;value (col1 = &amp;lt;fs_b&amp;gt;-col1 .. ) &lt;/EM&gt;?&lt;/P&gt;
  &lt;P&gt;Thank you,&lt;/P&gt;
  &lt;P&gt;Mario&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;
 data: lt_b type standard table of ty_b with key id "lt_a defined as an attribute somewhere else&lt;BR /&gt;....&lt;BR /&gt;
 sort lt_b by id.

 loop at lt_b assigning field-symbol(&amp;lt;fs_b&amp;gt;).&lt;BR /&gt;
   assign lt_a[ id = &amp;lt;fs_b&amp;gt;-id ]-subtable to field-symbol(&amp;lt;fs_a_subtable&amp;gt;).

  " which one is faster - corresponding or insert value.. ?            
   insert corresponding #( &amp;lt;fs_b&amp;gt; ) into table &amp;lt;fs_a_subtlable&amp;gt;. 
  
  " Commented out.. as corresponding is shorter (but is it slower ?)
   *  insert value lt_a(
   *  col1 = &amp;lt;fs_b&amp;gt;-col1
   *  col2 = &amp;lt;fs_b&amp;gt;-col2
   *  col3 = &amp;lt;fs_b&amp;gt;-col3&lt;BR /&gt;   *  col4 = &amp;lt;fs_b&amp;gt;-col4
   * ) into table &amp;lt;fs_a_subtable&amp;gt;.

  endloop.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Sep 2019 06:59:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087957#M1971546</guid>
      <dc:creator>mario_maisto</dc:creator>
      <dc:date>2019-09-12T06:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Slow Performance i.e. pimping up an internal table loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087958#M1971547</link>
      <description>&lt;P&gt;If the ids are unique Try to add hashed  key to the tables with components id and in your select get the results with order by id &lt;/P&gt;&lt;P&gt;Else add sorted key with non unique key id&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 07:50:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087958#M1971547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-09-12T07:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Slow Performance i.e. pimping up an internal table loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087959#M1971548</link>
      <description>&lt;P&gt;You need to work with sorted tables both with the same ID. You are going to see an incredible improvement in performance. Do not work never with this king of declaration like TYPE STANDARD TABLE for this king of development.&lt;/P&gt;&lt;P&gt;I imagine that you are working without HANA database. If you have HANA you can model a CDS view preparing the data.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 08:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087959#M1971548</guid>
      <dc:creator>ruben_rollano</dc:creator>
      <dc:date>2019-09-12T08:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Slow Performance i.e. pimping up an internal table loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087960#M1971549</link>
      <description>&lt;P&gt;best way is try joint or use for all entries first.&lt;/P&gt;&lt;P&gt;if your requirement is just move data like that, you may try FILTER or CORRESPONDING command too.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 08:23:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087960#M1971549</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-09-12T08:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Slow Performance i.e. pimping up an internal table loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087961#M1971550</link>
      <description>&lt;P&gt;Obviously, Ruben Rollano Carcajona, Xavier Joubert, Quynh Doan Manh - you were all correct, and by putting together those pieces, I improved the performance from 45 seconds to 1.6 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; !.&lt;BR /&gt;&lt;BR /&gt;So, i used sorted table with the key 'id' together with:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at lt_a assigning field-symbol(&amp;lt;fs_a&amp;gt;).
 &amp;lt;fs_a&amp;gt;-subtable = corresponding #( filter #( lt_b where id eq &amp;lt;fs_a&amp;gt;-id ) ).
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for the help!&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mario&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 09:08:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/slow-performance-i-e-pimping-up-an-internal-table-loop/m-p/12087961#M1971550</guid>
      <dc:creator>mario_maisto</dc:creator>
      <dc:date>2019-09-12T09:08:47Z</dc:date>
    </item>
  </channel>
</rss>

