<?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: loop statement performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078429#M1505629</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;very good answer Siegfried,&lt;/P&gt;&lt;P&gt;I think there were 2 much of wrong answers for the question think you cleared them all &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Nafran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Jul 2010 05:07:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-19T05:07:21Z</dc:date>
    <item>
      <title>loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078418#M1505618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA : LV_STBLG TYPE BKPF-STBLG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT SINGLE STBLG FROM BKPF INTO LV_STBLG WHERE BELNR = WA_FINAL-BELNR ."AND GJAHR = WA_FINAL-GJAHR.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;this statement im using with in loop and im using two loops .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u suggest me &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1&lt;/P&gt;&lt;P&gt;conditions&lt;/P&gt;&lt;P&gt;endloop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1&lt;/P&gt;&lt;P&gt;cond&lt;/P&gt;&lt;P&gt;endlloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     DATA : LV_STBLG TYPE BKPF-STBLG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT SINGLE STBLG FROM BKPF INTO LV_STBLG WHERE BELNR = WA_FINAL-BELNR ."AND GJAHR = WA_FINAL-GJAHR.&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;&lt;/P&gt;&lt;P&gt;it takes lot of time to get the output..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 08:50:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078418#M1505618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T08:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078419#M1505619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select statements should never be used in loops. Thats why you have FAE's.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 09:13:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078419#M1505619</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T09:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078420#M1505620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Vikranth said, never use select statement in loops. Think about the alternatives like FOR ALL ENTRIES statement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 09:19:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078420#M1505620</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T09:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078421#M1505621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using select statement how can i use the for all entries of my above condition for single filed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 09:29:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078421#M1505621</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T09:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078422#M1505622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use parallerl cursor technique.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 09:31:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078422#M1505622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T09:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078423#M1505623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you pls provide me sample code for that. above is my conditon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 09:55:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078423#M1505623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T09:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078424#M1505624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not think this select is a problem within a loop.&lt;/P&gt;&lt;P&gt;However, the select single cannot be met, as you haven't specified the BUKRS field.&lt;/P&gt;&lt;P&gt;If you execute the extended syntax check you will get a warning message for this.&lt;/P&gt;&lt;P&gt;Use a select xx into xxx from xxx up to 1 rows where  xxxx instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the problem is your nested loops over the same table.&lt;/P&gt;&lt;P&gt;Why do you loop over the table three times?&lt;/P&gt;&lt;P&gt;How many entries do you have in this internal table?&lt;/P&gt;&lt;P&gt;The conditions you check, can't you filter out entries before looping?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck, Miranda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 10:01:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078424#M1505624</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T10:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078425#M1505625</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;check [FOR ALL ENTRIES documentation|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm], there is an example and explanation how does it work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But be aware:&lt;/P&gt;&lt;P&gt;1. You should not use FOR ALL ENTRIES if internal table is empty, because all entries will be selected&lt;/P&gt;&lt;P&gt;2. You should not use FOR ALL ENTRIES if internal table contains more than approx. 1500 entries, because a select statement will be translated into a very short SQL statement and it will cause a short dump &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are working with more than approx. 1500 entries you have to consider something else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ado&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 10:07:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078425#M1505625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T10:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078426#M1505626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u can use read statement within the first loop if your condition fetches just one record. use forall entries for select. below code could be helpful to you. there could be some syntax errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of it_stblg occurs 0,&lt;/P&gt;&lt;P&gt;           belnr like bkpf-belnr,&lt;/P&gt;&lt;P&gt;           stblg like bkpf-stblg,&lt;/P&gt;&lt;P&gt;         end of it_stblg.&lt;/P&gt;&lt;P&gt;if it_final[] is not initial.&lt;/P&gt;&lt;P&gt;SELECT STBLG FROM BKPF INTO IT_STBLG &lt;/P&gt;&lt;P&gt;                          for all entries in it_final[]&lt;/P&gt;&lt;P&gt;                          WHERE BELNR = IT_FINAL-BELNR &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1 into wa_itab1_1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab1 into wa_itab1_2 &amp;lt;with conditions&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab1 into wa_itab1_3 &amp;lt;with conditions&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table it_stblg with key &amp;lt;condition&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 10:19:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078426#M1505626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T10:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078427#M1505627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also have the declaration "DATA : LV_STBLG TYPE BKPF-STBLG."outside the loop.&lt;/P&gt;&lt;P&gt;as this statement will executed for all the iteration of the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jul 2010 10:51:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078427#M1505627</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-15T10:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078428#M1505628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...... lots of wrong answers !!!!!!!!!!!!!!!!..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;2. You should not use FOR ALL ENTRIES if internal table contains more than approx. 1500 entries, because a select statement &amp;gt;will be translated into a very short SQL statement and it will cause a short dump &lt;/P&gt;&lt;P&gt;&amp;gt;If you are working with more than approx. 1500 entries you have to consider something else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;???, where does this come from, it is wrong. The limit (around 1500 but dependingon the conditions) is valid for the ranges, not for the FAE. The FAE will work with very large tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Never SELECT in LOOP&lt;/P&gt;&lt;P&gt;is wrong !  It is wrong if there is at least one exception, this is the SELECT SINGLE from a single record buffer. There the FAE is not working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; parallel cursor&lt;/P&gt;&lt;P&gt;no, necessary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... Wrong is also the original question, I gues it must be&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AR itab1
 ...
    LOOP at itab2

    ENDLOOP.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is not the SELECT SINGLE but the nested loop!!!!&lt;/P&gt;&lt;P&gt;Use a sorted table! or optimize it with READ BINARY SEARCH / LOOP FROM INDEX / EXIT (search for details).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jul 2010 10:33:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078428#M1505628</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-16T10:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078429#M1505629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;very good answer Siegfried,&lt;/P&gt;&lt;P&gt;I think there were 2 much of wrong answers for the question think you cleared them all &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Nafran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 05:07:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078429#M1505629</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T05:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: loop statement performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078430#M1505630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I beleive you can use select statement inside the loop.&lt;/P&gt;&lt;P&gt;because you are using 'select single' and this will fetch only one record from the buffer depending on your where condition.&lt;/P&gt;&lt;P&gt;So every time whenever your loop will execute it will check the condition and will give you one record.&lt;/P&gt;&lt;P&gt;It's like moving a values in a variable inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like:&lt;/P&gt;&lt;P&gt;loop at itab into wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;variable1 = wa_itab-field1.&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;here every time in a loop the value of field1 from table itab will be stored in variable1&lt;/P&gt;&lt;P&gt;and the variable1 should be an internal table type if you want to store multiple values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so&lt;/P&gt;&lt;P&gt;loop at itab in wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single var1 from &amp;lt;tab1&amp;gt; into &amp;lt;var2&amp;gt; where &amp;lt;var3&amp;gt; = wa_itab&amp;lt;field1&amp;gt;.&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;here for every value of &amp;lt;var3&amp;gt; =  wa_itab-field1, the select statement will fetch the value of 'var1' from &amp;lt;tab1&amp;gt;  and will store in &amp;lt;var2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this will clear your doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: we should not use SELECT END-SELECT statement inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Lalit Gupta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 17:03:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-statement-performance/m-p/7078430#M1505630</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T17:03:58Z</dc:date>
    </item>
  </channel>
</rss>

