<?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/2397617#M533828</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;Use for all entries or join.&lt;/P&gt;&lt;P&gt;Its better not to hit the entire db table using '*'.Its better if u retrieve only selected fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jun 2007 06:41:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-11T06:41:32Z</dc:date>
    <item>
      <title>SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397616#M533827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, what is the best way to  populate an internal table with multiple database table fields. give me some example code.&lt;/P&gt;&lt;P&gt;reward points if answered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 06:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397616#M533827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-11T06:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397617#M533828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;Use for all entries or join.&lt;/P&gt;&lt;P&gt;Its better not to hit the entire db table using '*'.Its better if u retrieve only selected fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 06:41:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397617#M533828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-11T06:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397618#M533829</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;Use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FOR ALL ENTIRES&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; or &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;JOINS&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FOR ALL ENTRIES&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; is an effective way of doing away with using &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;JOIN&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; on two tables.&lt;/P&gt;&lt;P&gt;You can check the below code -&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....

SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*******************************8&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;look another example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the use of FOR ALL ENTRIES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; INNER JOIN
DBTAB1 &amp;lt;------------&amp;gt; DBTAB2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is used to JOIN two &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATABASE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; tables&lt;/P&gt;&lt;P&gt;having some &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;COMMON&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whereas &lt;/P&gt;&lt;P&gt;For All Entries,&lt;/P&gt;&lt;P&gt;DBTAB1 &amp;lt;----&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;gt; ITAB1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is not at all related to two &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATABASE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is related to&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; INTERNAL&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; If we want to fetch data &lt;/P&gt;&lt;P&gt;from some &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DBTABLE1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but we want to fetch&lt;/P&gt;&lt;P&gt;for only some records&lt;/P&gt;&lt;P&gt;which are contained in some internal table,&lt;/P&gt;&lt;P&gt;then we use for alll entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*----&lt;/P&gt;&lt;HR originaltext="-----------------" /&gt;&lt;P&gt; simple example of for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; NOTE THAT &lt;/P&gt;&lt;P&gt;In for all entries,&lt;/P&gt;&lt;P&gt;it is NOT necessary to use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TWO DBTABLES.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(as against JOIN)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use this program (just copy paste)&lt;/P&gt;&lt;P&gt;it will fetch data&lt;/P&gt;&lt;P&gt;from T001&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FOR ONLY TWO COMPANIES&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; (as mentioned in itab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT abc.



DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

*--------------------

itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.


*--------------------

SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.


*--------------------------
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anversha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 06:44:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397618#M533829</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2007-06-11T06:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATEMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397619#M533830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sravangd Panjugula,   &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its an easy thing but make sure that you avoid using inner joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read tables one after another by using &amp;lt;b&amp;gt;FOR ALL ENTRIES&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once all the tables are read. Use &amp;lt;b&amp;gt;READ TABLE - WITH KEY&amp;lt;/b&amp;gt; criterion. This helps you to bring the data of all tables into one single table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward Points if useful.&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;Tej..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;null&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 06:47:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/2397619#M533830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-11T06:47:15Z</dc:date>
    </item>
  </channel>
</rss>

