<?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 statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555714#M251655</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes both of them behave the same way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to do is the second one. You need to get all the data into an ITAB and play with it. This is becuase when you use SELECT...ENDSELECT the database connection is open untill the whole data is looped through.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Sep 2006 17:57:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-12T17:57:51Z</dc:date>
    <item>
      <title>Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555712#M251653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to check if my understanding is correct.&lt;/P&gt;&lt;P&gt;Are the both example below performing the same looping?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, what is better recommended: use "select endselect" or loop at an internal table ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;Cristina&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example 1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM vbak&lt;/P&gt;&lt;P&gt;          WHERE&lt;/P&gt;&lt;P&gt;          kunnr =  gv_kunnr  AND&lt;/P&gt;&lt;P&gt;          erdat IN zdate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK sy-subrc = 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  	"do something"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example 2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;   INTO CORRESPONDING FIELDS OF TABLE IT_VBAK&lt;/P&gt;&lt;P&gt;	 FROM  vbak&lt;/P&gt;&lt;P&gt;         WHERE kunnr =  gv_kunnr  AND&lt;/P&gt;&lt;P&gt;               erdat IN zdate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   	"do something"&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;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:54:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555712#M251653</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T17:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555713#M251654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Database should not be hit often so it is always better to use the second option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE IT_VBAK&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;WHERE kunnr = gv_kunnr AND&lt;/P&gt;&lt;P&gt;erdat IN zdate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"do something"&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;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prakash.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:56:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555713#M251654</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T17:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555714#M251655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes both of them behave the same way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to do is the second one. You need to get all the data into an ITAB and play with it. This is becuase when you use SELECT...ENDSELECT the database connection is open untill the whole data is looped through.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:57:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555714#M251655</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T17:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555715#M251656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_VBAK&lt;/P&gt;&lt;P&gt;FROM vbak WHERE kunnr = gv_kunnr AND&lt;/P&gt;&lt;P&gt;                erdat IN zdate.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;LOOP AT it_vbak.&lt;/P&gt;&lt;P&gt;"do something"&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;---Suggestable,but&lt;/P&gt;&lt;P&gt;instead of ussing INTO CORRESPONDING,create an internal table with the required fields and use &amp;lt;b&amp;gt;into table it_vbak&amp;lt;/b&amp;gt; for better way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:58:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555715#M251656</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T17:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555716#M251657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both are doing the same but if you want a more efficient way then your example 2 is better.  The reason being, in Select-EndSelect there is a connection to the DB server and might take a lot of time compared to example 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hith&lt;/P&gt;&lt;P&gt;Sunil Achyut&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 17:59:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555716#M251657</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T17:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555717#M251658</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;1. It's useless to insert a CHECK SY-SUBRC = 0 statament into a SELECT/ENDSELECT, if it's into SELECT/ENDSELECT it means SELECT is done successefully so SY-SUBRC = 0:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM vbak WHERE kunnr = gv_kunnr AND &lt;/P&gt;&lt;P&gt;erdat IN zdate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;CHECK sy-subrc = 0. &amp;lt;------- Remove it&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"do something"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Here that control is useless, because if SY-SUBRC &amp;lt;&amp;gt; 0 it means no data was extracted so LOOP/ENDLOOP won't work and I don't believe you can see perfomance different so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE IT_VBAK&lt;/P&gt;&lt;P&gt;FROM vbak&lt;/P&gt;&lt;P&gt;WHERE kunnr = gv_kunnr AND&lt;/P&gt;&lt;P&gt;erdat IN zdate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"do something"&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;Anyway it's always better to work on internal table and SELECT ...INTO TABLE is faster than SELECT/ENDSELECT so the second option is better than first one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Sep 2006 18:02:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/1555717#M251658</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-12T18:02:22Z</dc:date>
    </item>
  </channel>
</rss>

