<?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: JOINS in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742654#M637354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi dhiraj&lt;/P&gt;&lt;P&gt;       1. No you can't , For outter join , you need the same field between two table that you join but there is  no need for the same data between there.&lt;/P&gt;&lt;P&gt;        2. SELECT &amp;lt;fieldlist&amp;gt; INTO &amp;lt;target&amp;gt; FROM &amp;lt;dbtab1&amp;gt; AS &amp;lt;alias1&amp;gt;&lt;/P&gt;&lt;P&gt;meaning is Selecting data of field  from table  and keep into variable and name the table as  a.&lt;/P&gt;&lt;P&gt;example&lt;/P&gt;&lt;P&gt;            select bukrs into v_bukrs from bsid as a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bukrs is field in table  &lt;/P&gt;&lt;P&gt;v_bukrs is variable that you declare&lt;/P&gt;&lt;P&gt;you name the table as a , next time you can mention this table as a .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;fieldlist&amp;gt; INTO &amp;lt;target&amp;gt;&lt;/P&gt;&lt;P&gt;FROM &amp;lt;dbtab1&amp;gt; AS &amp;lt;alias1&amp;gt;&lt;/P&gt;&lt;P&gt;INNER JOIN &amp;lt;dbtab2&amp;gt; AS &amp;lt;alias2&amp;gt;&lt;/P&gt;&lt;P&gt;ON &amp;lt;alaias1&amp;gt;&lt;SUB&gt;&amp;lt;dbtab1-field1&amp;gt; = &amp;lt;alials2&amp;gt;&lt;/SUB&gt;&amp;lt;dbtab2-field1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you have two table and two table have relationship , you select the data from two table by condition that link between two table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;select a.bukrs  b.xxx into (v_bukrs,v_xxx)&lt;/P&gt;&lt;P&gt;from  bsid as a &lt;/P&gt;&lt;P&gt;inner join bsad as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;mandt = b&lt;/SUB&gt;mandt &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you select data in field bukrs from table bsid and xxx from table bsad and keep into variable v_bukrs and v_xxx which condition that field mandt in the two table are the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Wiboon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Sep 2007 06:12:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-14T06:12:06Z</dc:date>
    <item>
      <title>JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742651#M637351</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;Can anybody please explain the following, if possible with an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. None of the fields in the table on the right can apear in the WHERE conditions of the LEFT OUTER JOIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. SELECT &amp;lt;fieldlist&amp;gt; INTO &amp;lt;target&amp;gt;&lt;/P&gt;&lt;P&gt;    FROM &amp;lt;dbtab1&amp;gt; AS &amp;lt;alias1&amp;gt;&lt;/P&gt;&lt;P&gt;    INNER JOIN &amp;lt;dbtab2&amp;gt; AS &amp;lt;alias2&amp;gt;&lt;/P&gt;&lt;P&gt;    ON &amp;lt;alaias1&amp;gt;&lt;SUB&gt;&amp;lt;dbtab1-field1&amp;gt; = &amp;lt;alials2&amp;gt;&lt;/SUB&gt;&amp;lt;dbtab2-field1&amp;gt;.&lt;/P&gt;&lt;P&gt;Please explain the about code specially the alaising involved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dhiraj Mehta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2007 05:47:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742651#M637351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-14T05:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742652#M637352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi dhiraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for outer joins go thro this document.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) it is just giving another name to the dbtable in the select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;take an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;matnr b&lt;/SUB&gt;werks into corresponding fields of table itab from mara as a inner join marc as b on a&lt;SUB&gt;matnr = b&lt;/SUB&gt;matnr.&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;Arun.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2007 05:58:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742652#M637352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-14T05:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742653#M637353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dhiraj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a sample code for your reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  a&lt;SUB&gt;aufnr a&lt;/SUB&gt;auart a&lt;SUB&gt;erdat a&lt;/SUB&gt;aenam a~ktext&lt;/P&gt;&lt;P&gt;               a&lt;SUB&gt;kostv a&lt;/SUB&gt;kostl a&lt;SUB&gt;objnr a&lt;/SUB&gt;kdauf a~kdpos&lt;/P&gt;&lt;P&gt;               a&lt;SUB&gt;adrnra a&lt;/SUB&gt;pspel a&lt;SUB&gt;ernam a&lt;/SUB&gt;zzact_cde&lt;/P&gt;&lt;P&gt;               b&lt;SUB&gt;priok b&lt;/SUB&gt;equnr b&lt;SUB&gt;bautl b&lt;/SUB&gt;iloan&lt;/P&gt;&lt;P&gt;               b&lt;SUB&gt;gewrk b&lt;/SUB&gt;addat b&lt;SUB&gt;qmnum b&lt;/SUB&gt;ilart&lt;/P&gt;&lt;P&gt;               c&lt;SUB&gt;arbpl c&lt;/SUB&gt;werks&lt;/P&gt;&lt;P&gt;               d&lt;SUB&gt;gltrp d&lt;/SUB&gt;gstrp d&lt;SUB&gt;gluzp d&lt;/SUB&gt;gsuzp d&lt;SUB&gt;maufnr d&lt;/SUB&gt;aufpl&lt;/P&gt;&lt;P&gt;               e&lt;SUB&gt;tplnr e&lt;/SUB&gt;abckz e&lt;SUB&gt;eqfnr e&lt;/SUB&gt;beber e~proid&lt;/P&gt;&lt;P&gt;               f~bstkd&lt;/P&gt;&lt;P&gt;               g&lt;SUB&gt;groes g&lt;/SUB&gt;inbdt g&lt;SUB&gt;eqart g&lt;/SUB&gt;eqtyp&lt;/P&gt;&lt;P&gt;                i~ktsch&lt;/P&gt;&lt;P&gt;               INTO TABLE i_order&lt;/P&gt;&lt;P&gt;               FROM aufk AS a  INNER JOIN afih  AS b ON a&lt;SUB&gt;aufnr = b&lt;/SUB&gt;aufnr&lt;/P&gt;&lt;P&gt;                                          INNER JOIN crhd  AS c ON c&lt;SUB&gt;objid = b&lt;/SUB&gt;gewrk&lt;/P&gt;&lt;P&gt;                                          INNER JOIN afko  AS d ON a&lt;SUB&gt;aufnr = d&lt;/SUB&gt;aufnr&lt;/P&gt;&lt;P&gt;                                          INNER JOIN iloa  AS e ON b&lt;SUB&gt;iloan = e&lt;/SUB&gt;iloan&lt;/P&gt;&lt;P&gt;                                          INNER JOIN pmsdo AS f ON f&lt;SUB&gt;objnr = a&lt;/SUB&gt;objnr&lt;/P&gt;&lt;P&gt;                                  LEFT OUTER JOIN equi  AS g ON g&lt;SUB&gt;equnr = b&lt;/SUB&gt;equnr&lt;/P&gt;&lt;P&gt;                                             INNER JOIN afvc  AS i ON i&lt;SUB&gt;aufpl = d&lt;/SUB&gt;aufpl&lt;/P&gt;&lt;P&gt;               WHERE a~aufnr   IN  s_aufnr&lt;/P&gt;&lt;P&gt;                   AND   a~auart   IN  p_auart&lt;/P&gt;&lt;P&gt;                   AND   a~kostv   IN  s_kostv&lt;/P&gt;&lt;P&gt;                   AND   a~kdauf   IN  s_kdauf&lt;/P&gt;&lt;P&gt;                   AND   b~ilart   IN  s_ilart&lt;/P&gt;&lt;P&gt;                   AND   b~equnr   IN  s_equi&lt;/P&gt;&lt;P&gt;                   AND   b~addat   IN  s_period&lt;/P&gt;&lt;P&gt;                   AND   b~iphas   IN  r_iphas&lt;/P&gt;&lt;P&gt;                   AND   b~priok   IN  s_proik&lt;/P&gt;&lt;P&gt;                   AND   c~arbpl   IN  s_arbpl&lt;/P&gt;&lt;P&gt;                   AND   c~werks   IN  s_werks&lt;/P&gt;&lt;P&gt;                   AND   d~maufnr  IN  s_maufnr&lt;/P&gt;&lt;P&gt;                   AND   d~gstrp   IN  s_gstrp&lt;/P&gt;&lt;P&gt;                   AND   d~gltrp   IN  s_gltrp&lt;/P&gt;&lt;P&gt;                   AND   e~beber   IN  s_beber&lt;/P&gt;&lt;P&gt;                   AND   e~stort   IN  s_stort&lt;/P&gt;&lt;P&gt;                   AND   e~tplnr   IN  s_tplnr&lt;/P&gt;&lt;P&gt;                   AND   f~bstkd   IN  s_bstkd&lt;/P&gt;&lt;P&gt;                   AND   i~loekz   NE  'X'.&lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can see that I have used so many inner joins.&lt;/P&gt;&lt;P&gt;The method of alaising comes when you have two tables with the same fieldname and you have distinguish between them.&lt;/P&gt;&lt;P&gt;For example in this sample code you have AUFNR in AUFK and AFIH table as well. But we are interested to pick only AUFNR from AUFK table and not from AFIH.&lt;/P&gt;&lt;P&gt;Therefore we write a~aufk in the select query &amp;lt; field list&amp;gt;.&lt;/P&gt;&lt;P&gt;I have also used the left outer join. But u can check that I have not used the fileds of the left outer join table equi. That is the way the syntax of a select query using joins are defined.&lt;/P&gt;&lt;P&gt;Similarly you can verify the other fields in the select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope its clear now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please award points if the answer is satisfactory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2007 06:03:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742653#M637353</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-14T06:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742654#M637354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi dhiraj&lt;/P&gt;&lt;P&gt;       1. No you can't , For outter join , you need the same field between two table that you join but there is  no need for the same data between there.&lt;/P&gt;&lt;P&gt;        2. SELECT &amp;lt;fieldlist&amp;gt; INTO &amp;lt;target&amp;gt; FROM &amp;lt;dbtab1&amp;gt; AS &amp;lt;alias1&amp;gt;&lt;/P&gt;&lt;P&gt;meaning is Selecting data of field  from table  and keep into variable and name the table as  a.&lt;/P&gt;&lt;P&gt;example&lt;/P&gt;&lt;P&gt;            select bukrs into v_bukrs from bsid as a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bukrs is field in table  &lt;/P&gt;&lt;P&gt;v_bukrs is variable that you declare&lt;/P&gt;&lt;P&gt;you name the table as a , next time you can mention this table as a .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;fieldlist&amp;gt; INTO &amp;lt;target&amp;gt;&lt;/P&gt;&lt;P&gt;FROM &amp;lt;dbtab1&amp;gt; AS &amp;lt;alias1&amp;gt;&lt;/P&gt;&lt;P&gt;INNER JOIN &amp;lt;dbtab2&amp;gt; AS &amp;lt;alias2&amp;gt;&lt;/P&gt;&lt;P&gt;ON &amp;lt;alaias1&amp;gt;&lt;SUB&gt;&amp;lt;dbtab1-field1&amp;gt; = &amp;lt;alials2&amp;gt;&lt;/SUB&gt;&amp;lt;dbtab2-field1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you have two table and two table have relationship , you select the data from two table by condition that link between two table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;select a.bukrs  b.xxx into (v_bukrs,v_xxx)&lt;/P&gt;&lt;P&gt;from  bsid as a &lt;/P&gt;&lt;P&gt;inner join bsad as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;mandt = b&lt;/SUB&gt;mandt &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you select data in field bukrs from table bsid and xxx from table bsad and keep into variable v_bukrs and v_xxx which condition that field mandt in the two table are the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Wiboon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2007 06:12:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2742654#M637354</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-14T06:12:06Z</dc:date>
    </item>
  </channel>
</rss>

