<?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/3714776#M894240</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer to the below related thread&lt;/P&gt;&lt;P&gt;/message/5219519#5219519 &lt;B&gt;[original link is broken]&lt;/B&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Apr 2008 14:54:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-29T14:54:59Z</dc:date>
    <item>
      <title>SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714774#M894238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;can u plz tell me ,&lt;/P&gt;&lt;P&gt;when to use 'for all entries' in select statement,&lt;/P&gt;&lt;P&gt;give one example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:52:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714774#M894238</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714775#M894239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pawan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement. &lt;/P&gt;&lt;P&gt;    SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result set. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records (in the current client). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT *
  FROM SCARR
  INTO TABLE t_scarr.

LOOP AT t_SCARR INTO wa_scarr.
  SELECT SINGLE *
    FROM sflight
    INTO wa_sflight
   WHERE carrid EQ wa_scarr-carrid.
 
  APPEND wa_sflight TO t_sflight.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of the Above use below code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT *
  FROM SCARR
  INTO TABLE t_scarr.

SELECT *
  FROM SFLIGHT
  INTO TABLE t_sflight
   FOR ALL ENTRIES IN scARR
 WHERE carrid EQ t_scarr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    this condition, return all entries of the sflight &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the Below Links for more Info:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sunil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:53:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714775#M894239</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714776#M894240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Refer to the below related thread&lt;/P&gt;&lt;P&gt;/message/5219519#5219519 &lt;B&gt;[original link is broken]&lt;/B&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:54:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714776#M894240</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714777#M894241</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;You use the &lt;STRONG&gt;for all entries&lt;/STRONG&gt; in a select when you want to do a join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Follow an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

SELECT * FROM scarr INTO TABLE lt_scarr.

IF lt_scarr[] IS NOT INITIAL.
  SELECT * FROM spfli INTO TABLE lt_spfli
    FOR ALL ENTRIES IN lt_scarr
    WHERE CARRID = lt_scarr-carrid.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the code above will be selected all records from table SPFLI where the CARRID exists in table SCARR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:56:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714777#M894241</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714778#M894242</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;Yo use For all entries when you need to select data with the "Where condition" based in a internal table already filled.&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;Fernando&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:56:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714778#M894242</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714779#M894243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI pawan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when u want to join two select statements u can use For all entries and some prerequiste for using for all entries is there should be some values in internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;      APPENDING CORRESPONDING FIELDS OF TABLE i_a081&lt;/P&gt;&lt;P&gt;      from a082&lt;/P&gt;&lt;P&gt;      for all entries in T_ESLHL_CONTR&lt;/P&gt;&lt;P&gt;      where kont_pack = T_ESLHL_CONTR-packno&lt;/P&gt;&lt;P&gt;        and kont_zeile = T_ESLHL_CONTR-introw&lt;/P&gt;&lt;P&gt;        and kappl = 'MS'&lt;/P&gt;&lt;P&gt;        and kschl = 'PRS'&lt;/P&gt;&lt;P&gt;        and datab LE p_pr_dat&lt;/P&gt;&lt;P&gt;        and datbi GE p_pr_dat.&lt;/P&gt;&lt;P&gt;*}&lt;/P&gt;&lt;P&gt;    if not i_a081 is initial.&lt;/P&gt;&lt;P&gt;      sort i_a081.&lt;/P&gt;&lt;P&gt;      select *&lt;/P&gt;&lt;P&gt;        into table i_konp&lt;/P&gt;&lt;P&gt;        from konp&lt;/P&gt;&lt;P&gt;        for all entries in i_a081&lt;/P&gt;&lt;P&gt;        where knumh = i_a081-knumh&lt;/P&gt;&lt;P&gt;          and kappl = i_a081-kappl&lt;/P&gt;&lt;P&gt;          and kschl = i_a081-kschl&lt;/P&gt;&lt;P&gt;          and loevm_ko = space.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i_a081and i_a082 are the two internal tables see how they are used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rewards points if useful please&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;abdul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 14:59:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714779#M894243</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714780#M894244</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;You can use For All Entries Statement inorder to fetch the data from more that 1 tables based on the Primary key. i.e here we are joinning more than one tables to extract the required fields. &lt;/P&gt;&lt;P&gt;For all entries is advisable rather than Inner joins because, we are hitting the database at once and putting the data into Internal table and then we perform the For All Entries. Where as the Inner Joins hit the database itself for all the required no.of records..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here I provide you an example where you can select the data from two tables: vbak and vbap..using For All Entries:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln&lt;/P&gt;&lt;P&gt;       vkorg&lt;/P&gt;&lt;P&gt;       vtweg&lt;/P&gt;&lt;P&gt;       spart&lt;/P&gt;&lt;P&gt;       from vbak&lt;/P&gt;&lt;P&gt;       into table it_vbak&lt;/P&gt;&lt;P&gt;       where vbeln in s_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_vbak[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln&lt;/P&gt;&lt;P&gt;       posnr&lt;/P&gt;&lt;P&gt;       matnr&lt;/P&gt;&lt;P&gt;       netwr&lt;/P&gt;&lt;P&gt;       brgew&lt;/P&gt;&lt;P&gt;       ntgew&lt;/P&gt;&lt;P&gt;       from vbap&lt;/P&gt;&lt;P&gt;       into table it_vbap&lt;/P&gt;&lt;P&gt;       for all entries in it_vbak&lt;/P&gt;&lt;P&gt;       where vbeln = it_vbak-vbeln.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; loop at it_vbap.&lt;/P&gt;&lt;P&gt; read table it_vbak with key vbeln = it_vbap-vbeln.&lt;/P&gt;&lt;P&gt; if sy-subrc = 0.&lt;/P&gt;&lt;P&gt; move: it_vbak-vbeln to it_final-vbeln,&lt;/P&gt;&lt;P&gt;       it_vbak-vkorg to it_final-vkorg,&lt;/P&gt;&lt;P&gt;       it_vbak-vtweg to it_final-vtweg,&lt;/P&gt;&lt;P&gt;       it_vbak-spart to it_final-spart,&lt;/P&gt;&lt;P&gt;       it_vbap-posnr to it_final-posnr,&lt;/P&gt;&lt;P&gt;       it_vbap-matnr to it_final-matnr,&lt;/P&gt;&lt;P&gt;       it_vbap-netwr to it_final-netwr,&lt;/P&gt;&lt;P&gt;       it_vbap-brgew to it_final-brgew,&lt;/P&gt;&lt;P&gt;       it_vbap-ntgew to it_final-ntgew.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append it_final.&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;Reena&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 15:04:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3714780#M894244</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-29T15:04:24Z</dc:date>
    </item>
  </channel>
</rss>

