<?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: Regarding Select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039716#M965547</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;First query is wrong, because there can be more then 1 record you select. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should be &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select * into [table]
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select * into [structure] "(or fields, as in your case) 
* works as a loop, inserting every row into structure/fields, one by one
Endselect.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select single * into [structure] 
* first row is taken 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chears &lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Jun 2008 11:00:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-12T11:00:07Z</dc:date>
    <item>
      <title>Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039712#M965543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi below are given 2 queries:&lt;/P&gt;&lt;P&gt;              &lt;/P&gt;&lt;P&gt;     select bukrs&lt;/P&gt;&lt;P&gt;               gjahr&lt;/P&gt;&lt;P&gt;               belnr&lt;/P&gt;&lt;P&gt;       from bkpf&lt;/P&gt;&lt;P&gt;       into (t_bkpf-bukrs, t_bkpf-gjahr, t_bkpf-belnr)&lt;/P&gt;&lt;P&gt;       where awkey = t_vbrk-vbeln3&lt;/P&gt;&lt;P&gt;         and bukrs = t_vbrk-bukrs&lt;/P&gt;&lt;P&gt;         and blart = 'RV'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**********************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT SINGLE     &lt;/P&gt;&lt;P&gt;         from bkpf&lt;/P&gt;&lt;P&gt;               bukrs&lt;/P&gt;&lt;P&gt;               gjahr&lt;/P&gt;&lt;P&gt;               belnr&lt;/P&gt;&lt;P&gt;          FROM bkpf&lt;/P&gt;&lt;P&gt;          INTO (t_bkpf-bukrs, t_bkpf-gjahr, t_bkpf-belnr)&lt;/P&gt;&lt;P&gt;         WHERE awkey = t_vbrk-vbeln3&lt;/P&gt;&lt;P&gt;           AND bukrs = t_vbrk-bukrs&lt;/P&gt;&lt;P&gt;           AND blart = 'RV'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the difference is only SINGLE keyword.&lt;/P&gt;&lt;P&gt;my question is which query is wrong and why.&lt;/P&gt;&lt;P&gt;Please answer with detail description.&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 10:52:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039712#M965543</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T10:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039713#M965544</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;      In BKPF we have BUKRS, BELNR as primary keys, so there is a chance of getting the muliple records (by hitting the table with non primary keys), so by just getting the data to the work area is not recommended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      We should use &lt;STRONG&gt;select single&lt;/STRONG&gt; when we are using full bunch of primary keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      So I suggest to use &lt;STRONG&gt;select -- endselect up to 1 rows&lt;/STRONG&gt; to archive your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 10:56:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039713#M965544</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T10:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039714#M965545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1st query wil show u error , u hve to put endselect in 1st one , in 2nd one it wil execute without error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;both the methods are correct , it depend upon ur requirement whether u want to fetch single value on condition basis or multiple values&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 10:57:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039714#M965545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T10:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039715#M965546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hii&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First query is right&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in second query little mistake is there..From should not be there after SINGLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT SINGLE kunnr
      FROM kna1
      INTO w_kna1
      WHERE kunnr = w_kunnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;difference between two queries is first query will fetch all the data which will match to your condition.it can be one raw or more then one raw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But by using second query you will get single record that will match to your condition.if more then one record exist then it will give you a very first record as your o/p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;twinkal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 10:57:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039715#M965546</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T10:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039716#M965547</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;First query is wrong, because there can be more then 1 record you select. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should be &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select * into [table]
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select * into [structure] "(or fields, as in your case) 
* works as a loop, inserting every row into structure/fields, one by one
Endselect.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select single * into [structure] 
* first row is taken 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chears &lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 11:00:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039716#M965547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T11:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039717#M965548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   The first select statement goes wrong if the query is retrieving more than one record. In order to avoid that u can use select ..append itab....endselect. or select query .. into table .. where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  The use of select single is used to retrieve single record and place it in corresponding variables. this can be used when ever u want to retrieve only one record by passing all the key values for conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds.,&lt;/P&gt;&lt;P&gt;subash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 11:02:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039717#M965548</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T11:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039718#M965549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First question..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when using t_vbrk in where clause, where is the for all entries option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single can be used if you have fully qualified primary keys. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select end-select will do a database hit twice. Performance wise select single is better. But if Primary keys are not available u can use select end select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For both the options, use a work area in INTO clause&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 11:06:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-select-statement/m-p/4039718#M965549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T11:06:05Z</dc:date>
    </item>
  </channel>
</rss>

