<?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 How to avoid data selection inside the loop? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253723#M1829613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on one performance item and I have already applied some changes to the original version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my &lt;A _jive_internal="true" href="https://answers.sap.com/message/15025644#15025644"&gt;research&lt;/A&gt; (Below run is updating around 20M records which is real time volume for this application).&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/447241" width="450" /&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;1. Select data from ZABC&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;3. Loop Variant Table&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;4. Select data from X, Y, Z table for Var&amp;lt;n&amp;gt;.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;5. Populate final internal table from ZABC, X, Y and Z table&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;6. Modify ZTABLE with Final Internal table data&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;7. End Loop on Variant Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN class="L0S52"&gt;select &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr &lt;SPAN class="L0S52"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;( amt1&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;as amt1&amp;nbsp; "Like I have 32 amount fields in original query&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;from &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;zabc&lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;into &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;table &lt;/SPAN&gt;i_zabc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;where &lt;/SPAN&gt;ryear &lt;SPAN class="L0S52"&gt;in &lt;/SPAN&gt;r_year&amp;nbsp;&amp;nbsp;&amp;nbsp; " Two records in ranges with I and EQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rvers &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'001'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rrcty &lt;SPAN class="L0S52"&gt;in &lt;/SPAN&gt;r_rrcty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Three records in ranges with I and EQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rldnr &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'DT'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;group &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;by &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;order &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;by &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;




&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="bar" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, &lt;STRONG&gt;I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should &lt;SPAN style="color: #ff0000;"&gt;move ZABC selection inside the variant loop&lt;/SPAN&gt; which can cause fetching ZABC data 12 times&lt;/STRONG&gt; (Let me know If I am missing anything here).&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;Now, third statement in my trace results, with 10% of overall time is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;DIV style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;loop &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;at&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; i_abc assigning &amp;lt;fs_abc&amp;gt;.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;...&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;loop &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;at&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; i_table assigning &amp;lt;fs_table&amp;gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; low &amp;lt;= &amp;lt;fs_abc&amp;gt;-racct &lt;/SPAN&gt;&lt;SPAN class="op" style="font-weight: inherit; font-style: inherit; color: #808080;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; high &amp;gt;= &amp;lt;fs_abc&amp;gt;-racct.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;...&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;endloop.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit; font-family: inherit; font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit; font-family: inherit; font-size: 10pt;"&gt;endloop.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;2) Removed WHERE condition on HIGH only and applied filter inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Any suggestions on how to proceed with ZABC selection and I_TABLE loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Let me know if you have any questions on above compose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 May 2014 20:48:25 GMT</pubDate>
    <dc:creator>naveen_inuganti2</dc:creator>
    <dc:date>2014-05-06T20:48:25Z</dc:date>
    <item>
      <title>How to avoid data selection inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253723#M1829613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on one performance item and I have already applied some changes to the original version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my &lt;A _jive_internal="true" href="https://answers.sap.com/message/15025644#15025644"&gt;research&lt;/A&gt; (Below run is updating around 20M records which is real time volume for this application).&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/447241" width="450" /&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;1. Select data from ZABC&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;3. Loop Variant Table&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;4. Select data from X, Y, Z table for Var&amp;lt;n&amp;gt;.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;5. Populate final internal table from ZABC, X, Y and Z table&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;6. Modify ZTABLE with Final Internal table data&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;7. End Loop on Variant Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN class="L0S52"&gt;select &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr &lt;SPAN class="L0S52"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;( amt1&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;as amt1&amp;nbsp; "Like I have 32 amount fields in original query&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;from &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;zabc&lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;into &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;table &lt;/SPAN&gt;i_zabc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;where &lt;/SPAN&gt;ryear &lt;SPAN class="L0S52"&gt;in &lt;/SPAN&gt;r_year&amp;nbsp;&amp;nbsp;&amp;nbsp; " Two records in ranges with I and EQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rvers &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'001'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rrcty &lt;SPAN class="L0S52"&gt;in &lt;/SPAN&gt;r_rrcty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Three records in ranges with I and EQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;and &lt;/SPAN&gt;rldnr &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'DT'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;group &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;by &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;order &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;by &lt;/SPAN&gt;rrcty ryear rbukrs racct rcntr&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;




&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="bar" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, &lt;STRONG&gt;I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should &lt;SPAN style="color: #ff0000;"&gt;move ZABC selection inside the variant loop&lt;/SPAN&gt; which can cause fetching ZABC data 12 times&lt;/STRONG&gt; (Let me know If I am missing anything here).&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #333333;"&gt;Now, third statement in my trace results, with 10% of overall time is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="bar" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;DIV style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;loop &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;at&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; i_abc assigning &amp;lt;fs_abc&amp;gt;.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;...&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;loop &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;at&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; i_table assigning &amp;lt;fs_table&amp;gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; low &amp;lt;= &amp;lt;fs_abc&amp;gt;-racct &lt;/SPAN&gt;&lt;SPAN class="op" style="font-weight: inherit; font-style: inherit; color: #808080;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt; high &amp;gt;= &amp;lt;fs_abc&amp;gt;-racct.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;...&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;endloop.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit; font-family: inherit; font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit; font-family: inherit; font-size: 10pt;"&gt;endloop.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;2) Removed WHERE condition on HIGH only and applied filter inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Any suggestions on how to proceed with ZABC selection and I_TABLE loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;Let me know if you have any questions on above compose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 20:48:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253723#M1829613</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2014-05-06T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid data selection inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253724#M1829614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since I looked at this case before, let me try some quick suggestions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is table ZABC related to table X, Y and/or Z and can the selection be limited by applying those 12 selection variants?&lt;/P&gt;&lt;P&gt;If yes, try a join select involving these tables that could make your step 1 obsolete and replace steps 4 and 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might also get rid of the "loop inside loop" problem. Generally, make sure that the inner table is declared as a sorted table with a key that consists of the fields as used in the WHERE-condition of the inner loop. Use secondary keys for internal tables if your ABAP release permits and the task at hand warrants it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, look at PACKAGE SIZE option for the (join) select to reduce memory consumption.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2014 07:30:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253724#M1829614</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2014-05-07T07:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid data selection inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253725#M1829615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can try that... but I am not sure if that is going to work in my case. Because....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. Table X and Y are coming from one standard function module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Table Z is already result of inner join on Z1 and Z2. It has around 30 fields and good amount of data in target table, now if I link this to ZABC, it will increase total field count to 60-70 and program cannot deal with that much data (I will verify this once again).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. Most important thing is ZABC data is same for all 12 variants. Hence, even if I go for inner join with variant specific info, query is still going to fetch entire data. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4. I cannot get data from X, Y, Z at once for all variants because program cannot process entire data in one go! (It has to update custom db table within this loop).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2014 11:55:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253725#M1829615</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2014-05-07T11:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid data selection inside the loop?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253726#M1829616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! Now, I am using inner join to filter some data and applied grouping and it has significantly decrease data volume... now it there shouldn't be any memory allocation issues for my program or query. It also resolved the issue with that where condition!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 May 2014 20:12:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-data-selection-inside-the-loop/m-p/10253726#M1829616</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2014-05-11T20:12:20Z</dc:date>
    </item>
  </channel>
</rss>

