<?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 SELECT inside a loop ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220437#M136192</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello friends, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just woundring if someone advise me something better &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I have a loop and inside a loop I am seleting something ( one field ). So I am using following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at lt_lfa1 into ts_lfa1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT lifnr FROM lfb1&lt;/P&gt;&lt;P&gt;         INTO  lv_lifnr&lt;/P&gt;&lt;P&gt;         WHERE lifnr EQ ts_lfa1-lifnr&lt;/P&gt;&lt;P&gt;         AND  ....&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;Okey, as I am not selecting result in a table instead a field, i get error, that I have to provide endselect statement ( which I dont want ( due to performance reason). so the only solution I know is to use statement :&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE bla bla.. ( to avoid select endselect stuff). but as I am selecting only 1 field its also not convinient that I create a new internal table, ... so do any one here knows, how to not use select-endselect while selecting only one field ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Mar 2006 09:07:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-03-24T09:07:19Z</dc:date>
    <item>
      <title>SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220437#M136192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello friends, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just woundring if someone advise me something better &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I have a loop and inside a loop I am seleting something ( one field ). So I am using following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at lt_lfa1 into ts_lfa1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT lifnr FROM lfb1&lt;/P&gt;&lt;P&gt;         INTO  lv_lifnr&lt;/P&gt;&lt;P&gt;         WHERE lifnr EQ ts_lfa1-lifnr&lt;/P&gt;&lt;P&gt;         AND  ....&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;Okey, as I am not selecting result in a table instead a field, i get error, that I have to provide endselect statement ( which I dont want ( due to performance reason). so the only solution I know is to use statement :&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE bla bla.. ( to avoid select endselect stuff). but as I am selecting only 1 field its also not convinient that I create a new internal table, ... so do any one here knows, how to not use select-endselect while selecting only one field ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:07:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220437#M136192</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220438#M136193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;use SELECT SINGLE

SELECT SINGLE lifnr FROM lfb1
INTO lv_lifnr
WHERE lifnr EQ ts_lfa1-lifnr
AND ....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sekhar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:10:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220438#M136193</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220439#M136194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi shah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use &lt;/P&gt;&lt;P&gt;Loop at lt_lfa1 into ts_lfa1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select single lifnr FROM lfb1&lt;/P&gt;&lt;P&gt;INTO lv_lifnr&lt;/P&gt;&lt;P&gt;WHERE lifnr EQ ts_lfa1-lifnr&lt;/P&gt;&lt;P&gt;AND ....&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;thanks,&lt;/P&gt;&lt;P&gt;priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:10:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220439#M136194</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220440#M136195</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;The following code should work correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA LT_LIFNR TYPE LIFNR OCCURS 0 WITH HEADER LINE.

SELECT LIFNR
  FROM LFB1
 INTO TABLE LT_LIFNR
  FOR ALL ENTRIES IN LT_LFA1 WHERE LIFNR = LT_LFA1-LIFNR.

LOOP AT LT_LIFNR.
  WRITE : / LT_LIFNR.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please do let me nkow if it worked. You just need to assign the points to this answer....:-)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:11:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220440#M136195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220441#M136196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi shah,&lt;/P&gt;&lt;P&gt;        Use &amp;lt;b&amp;gt;Select Single&amp;lt;/b&amp;gt; Statement or Select * from dbtable in to table itab2 &amp;lt;b&amp;gt;for all entries&amp;lt;/b&amp;gt; of itab..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:12:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220441#M136196</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220442#M136197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thx for your replies:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh that was much simple, actually I am new to ABAP world , well point awared on the basis of first come, first serve!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks again &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:15:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220442#M136197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220443#M136198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;Actually I have a loop and inside a loop I am seleting something ( one field ). So I am using following:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest if you could avoid using a Select inside a loop due to performance reason. I would suggest you to make use of read statement using Binary search inside a loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Again scenario dependendent.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Suggestion steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Select the record into an internal table before loop , say itab  using Array fetch.&lt;/P&gt;&lt;P&gt;2) Sort ur itab&lt;/P&gt;&lt;P&gt;3) Use Loop at lt_lfa1 into ts_lfa1.&lt;/P&gt;&lt;P&gt;4) In that loop used read statement along with binary search .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the above steps you can get read of inface Select and Endselect also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other wise &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use select single inside the loop to avoid endselect , if ur reqmt. is like that only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if that helps or still if u have any doubts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;P&gt;Rewrd points, if found helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:19:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220443#M136198</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220444#M136199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thx for ur input, humm..intresting senario, which you have provide, will later give it a try, and will let you know, at the moment, have to move on to my current problem &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 09:34:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220444#M136199</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-24T09:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220445#M136200</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;Using a select statement inside a loop reduces the performance and increases the run time and the frequency of Database access . &lt;/P&gt;&lt;P&gt;Try this code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;select lifnr into table lt_lfb1&lt;/P&gt;&lt;P&gt;from lfb1&lt;/P&gt;&lt;P&gt;where key element is not null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at lt_lfa1 into ts_lfa1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table lt_lfb1 into ts_lfb1 with key                 lifnr eq ts_lfa1-lifnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt;clear ts_lfb1 . &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Mar 2006 06:40:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220445#M136200</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-27T06:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT inside a loop ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220446#M136201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi one could also join the two tables and loop once......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Mar 2006 14:02:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-a-loop/m-p/1220446#M136201</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-27T14:02:31Z</dc:date>
    </item>
  </channel>
</rss>

