<?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: problem with innor join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687341#M302399</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;comin to ur first question of for all entries ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for all entries is useful wen u need to avoid nested select statements .&lt;/P&gt;&lt;P&gt;consider the foll example ..&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; select * from &amp;lt;table1&amp;gt; into wa1 .&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  select * from &amp;lt;table2&amp;gt; into wa2 where &amp;lt;field1&amp;gt; eq wa1-&amp;lt;field1&amp;gt; .&lt;/P&gt;&lt;P&gt;    processing ...&lt;/P&gt;&lt;P&gt;  endselect .&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;now in the above case u will b again n again requesting data from database .&lt;/P&gt;&lt;P&gt;a better practice would be to program it in foll manner .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table1&amp;gt; into table itab1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table2&amp;gt; into table itab2 for all entries in itab1 where &amp;lt;field1&amp;gt; eq itab1-field1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this performs union of all the result set for each entry in itab1 .&lt;/P&gt;&lt;P&gt;so duplicate rows r removed .&lt;/P&gt;&lt;P&gt;and one more thing 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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now inner-join ...&lt;/P&gt;&lt;P&gt;inner join is mostly used when u need certain fields of one database table and other database table which have some fields in common .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can use it a follows ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;field1 a&lt;/SUB&gt;field2  b~field3 into table &amp;lt;itab1&amp;gt; from &amp;lt;db1&amp;gt; &lt;/P&gt;&lt;P&gt;as inner join &amp;lt;db2&amp;gt; as b on a&lt;SUB&gt;field1 eq b&lt;/SUB&gt;field1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if helpful then plz reward points ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reagards ,&lt;/P&gt;&lt;P&gt; swapnil .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Nov 2006 06:36:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-24T06:36:40Z</dc:date>
    <item>
      <title>problem with innor join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687339#M302397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sdn exports,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) when we go for "for all entries , and when we go for innor join " concept?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 15:56:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687339#M302397</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T15:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: problem with innor join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687340#M302398</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;"FOR ALL ENTRIES IN..." (outer join) are very fast but keep in the mind the special features and 3 pitfalls of using it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(a) Duplicates are removed from the answer set as if you had specified "SELECT DISTINCT"... So unless you intend for duplicates to be deleted include the unique key of the detail line items in your select statement. In the data dictionary (SE11) the fields belonging to the unique key are marked with an "X" in the key column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(b) If the "one" table (the table that appears in the clause FOR ALL ENTRIES IN) is empty, all rows in the "many" table (the table that appears in the SELECT INTO clause ) are selected. Therefore make sure you check that the "one" table has rows before issuing a select with the "FOR ALL ENTRIES IN..." clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(c) If the 'one' table (the table that appears in the clause FOR ALL ENTRIES IN) is very large there is performance degradation Steven Buttiglieri created sample code to illustrate this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proper use of Inner Join&lt;/P&gt;&lt;P&gt;When multiple SAP tables are logically joined, it is always advisable to use inner join to read the data from them. This certainly reduces the load on the network. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             Select a&lt;SUB&gt;airln a&lt;/SUB&gt;lnnam b&lt;SUB&gt;fligh b&lt;/SUB&gt;cntry into table int_airdet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            From zairln as a inner join zflight as b on a&lt;SUB&gt;airln = b&lt;/SUB&gt;airln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 16:04:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687340#M302398</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-23T16:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: problem with innor join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687341#M302399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;comin to ur first question of for all entries ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for all entries is useful wen u need to avoid nested select statements .&lt;/P&gt;&lt;P&gt;consider the foll example ..&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; select * from &amp;lt;table1&amp;gt; into wa1 .&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  select * from &amp;lt;table2&amp;gt; into wa2 where &amp;lt;field1&amp;gt; eq wa1-&amp;lt;field1&amp;gt; .&lt;/P&gt;&lt;P&gt;    processing ...&lt;/P&gt;&lt;P&gt;  endselect .&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;now in the above case u will b again n again requesting data from database .&lt;/P&gt;&lt;P&gt;a better practice would be to program it in foll manner .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table1&amp;gt; into table itab1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table2&amp;gt; into table itab2 for all entries in itab1 where &amp;lt;field1&amp;gt; eq itab1-field1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this performs union of all the result set for each entry in itab1 .&lt;/P&gt;&lt;P&gt;so duplicate rows r removed .&lt;/P&gt;&lt;P&gt;and one more thing 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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now inner-join ...&lt;/P&gt;&lt;P&gt;inner join is mostly used when u need certain fields of one database table and other database table which have some fields in common .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can use it a follows ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;field1 a&lt;/SUB&gt;field2  b~field3 into table &amp;lt;itab1&amp;gt; from &amp;lt;db1&amp;gt; &lt;/P&gt;&lt;P&gt;as inner join &amp;lt;db2&amp;gt; as b on a&lt;SUB&gt;field1 eq b&lt;/SUB&gt;field1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if helpful then plz reward points ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reagards ,&lt;/P&gt;&lt;P&gt; swapnil .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2006 06:36:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687341#M302399</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-24T06:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: problem with innor join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687342#M302400</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;&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.&lt;/P&gt;&lt;P&gt;You can check the below code -&lt;/P&gt;&lt;P&gt;SELECT BUKRS BELNR GJAHR AUGDT&lt;/P&gt;&lt;P&gt;FROM BSEG&lt;/P&gt;&lt;P&gt;INTO TABLE I_BSEG&lt;/P&gt;&lt;P&gt;WHERE BUKRS = ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BUKRS BELNR BLART BLDAT&lt;/P&gt;&lt;P&gt;FROM BKPF&lt;/P&gt;&lt;P&gt;INTO TABLE I_BKPF&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN I_BSEG&lt;/P&gt;&lt;P&gt;WHERE BUKRS = I_BSEG-BUKRS&lt;/P&gt;&lt;P&gt;AND BELNR = I_BSEG-BELNR&lt;/P&gt;&lt;P&gt;AND BLDAT IN SO_BLDAT.&lt;/P&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;P&gt;1. INNER JOIN&lt;/P&gt;&lt;P&gt;DBTAB1 &amp;lt;----&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;gt; DBTAB2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is used to JOIN two DATABASE tables&lt;/P&gt;&lt;P&gt;having some COMMON fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. 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 DATABASE tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is related to INTERNAL table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If we want to fetch data &lt;/P&gt;&lt;P&gt;from some DBTABLE1&lt;/P&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;1. simple example of for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. NOTE THAT &lt;/P&gt;&lt;P&gt;In for all entries,&lt;/P&gt;&lt;P&gt;it is NOT necessary to use TWO DBTABLES.&lt;/P&gt;&lt;P&gt;(as against JOIN)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. 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;P&gt;FOR ONLY TWO COMPANIES (as mentioned in itab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4&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;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2006 06:41:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-innor-join/m-p/1687342#M302400</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-24T06:41:37Z</dc:date>
    </item>
  </channel>
</rss>

