<?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: Select within loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015438#M1608180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can confirm, as soon as you are selecting here from different tables, you are on a safe side. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jul 2011 12:13:56 GMT</pubDate>
    <dc:creator>yuri_ziryukin</dc:creator>
    <dc:date>2011-07-26T12:13:56Z</dc:date>
    <item>
      <title>Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015432#M1608174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to aviod the below select statement within a loop statement , got to know that this select cannot be avioded by other colleagues. Any suggestions?&lt;/P&gt;&lt;P&gt;Have also searched the forum, and got to know that not all selects within loops are avioded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here , inside the table t_t682i, I need entries where KSCHL = ZP17. But If I aviod the loop using READ statment, &lt;/P&gt;&lt;P&gt;the possibility is , I dont find any values for the first entry of ZP17 , then I have to go to second entry and get the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    LOOP AT t_t682i ASSIGNING &amp;lt;lfs_t682i&amp;gt;.
        SELECT  kschl
                      vkorg
                      matnr
                      knumh
                      INTO TABLE t_knumh_mrp
                      *FROM  (&amp;lt;lfs_t682i&amp;gt;-atab)*
                      FOR ALL ENTRIES IN lt_mkpf_mseg
                      WHERE kschl = zp17
                      AND vkorg = in02
                      AND matnr = lt_mkpf_mseg-matnr
                      AND ( datab LE lt_mkpf_mseg-budat AND datbi GE
                      lt_mkpf_mseg-budat ).
 ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: B@SAP123 on Jul 25, 2011 2:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 09:28:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015432#M1608174</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-25T09:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015433#M1608175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT t_t682i ASSIGNING &amp;lt;lfs_t682i&amp;gt;.
        SELECT  ....
                      INTO TABLE t_knumh_mrp
                      *FROM  (&amp;lt;lfs_t682i&amp;gt;-atab)*
                      FOR ALL ENTRIES IN lt_mkpf_mseg
                      WHERE kschl = zp17
                      AND vkorg = in02
                      AND matnr = lt_mkpf_mseg-matnr
                      AND ( datab LE lt_mkpf_mseg-budat AND datbi GE
                      lt_mkpf_mseg-budat ).
 ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you selecting data dynamically from the DDIC table, whose name is maintained in &lt;EM&gt;&amp;lt;lfs_t682i&amp;gt;-atab&lt;/EM&gt; ? If yes, i can't think of any logic to avoid the LOOP!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 09:39:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015433#M1608175</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-07-25T09:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015434#M1608176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suhas, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;Yes. The DDIC table name from which I need to select is in the table t_t682i  (&amp;lt;lfs_t682i&amp;gt;-atab  )  , I am selecting dynamically&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vijaya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 09:46:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015434#M1608176</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-25T09:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015435#M1608177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Vijaya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure that you've done a D.A.D from  &lt;EM&gt;t_t682i&lt;/EM&gt; based on the field &lt;EM&gt;atab&lt;/EM&gt; &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT inside LOOP is not suggested if you're selecting data from the same DB table. In your case it is more like selecting data from different tables(which are not known till runtime).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be the performance gurus might have something to add.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 10:29:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015435#M1608177</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-07-25T10:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015436#M1608178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Suhas,&lt;/P&gt;&lt;P&gt;Thanks. May be basic question, but could nto get what you meant by &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ""   make sure that you've done a D.A.D from t_t682i based on the field atab  ""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it was to mean to SORTING, deleting the duplicates from the table , then yes, I have done that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: B@SAP123 on Jul 25, 2011 5:10 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 11:39:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015436#M1608178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-25T11:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015437#M1608179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Vijaya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;If it was to mean to SORTING, deleting the duplicates from the table , then yes, I have done that.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you've deleted the duplicates from the internal table &lt;EM&gt;t_t682i&lt;/EM&gt; , i don't think there should be problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 14:40:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015437#M1608179</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-07-25T14:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015438#M1608180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can confirm, as soon as you are selecting here from different tables, you are on a safe side. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 12:13:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015438#M1608180</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-07-26T12:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015439#M1608181</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;Try to take join and use for all interies instead of select inside loop.&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;Amit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 08:21:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015439#M1608181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-28T08:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015440#M1608182</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;Selecting data from the same table inside a loop is a performance issue.&lt;/P&gt;&lt;P&gt;in your case, u r selecting the details from differnt database tables which is known only at run time. i feel this is not at all a performance issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 15:48:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015440#M1608182</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-11T15:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015441#M1608183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second gayatri. In any case this is an interesting read.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 13:54:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015441#M1608183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-18T13:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015442#M1608184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;loop with read statement is better i thnk?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 15:41:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-within-loop/m-p/8015442#M1608184</guid>
      <dc:creator>Lokes</dc:creator>
      <dc:date>2011-08-23T15:41:32Z</dc:date>
    </item>
  </channel>
</rss>

