<?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: Inner Join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703687#M308353</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;chk this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select a~field1, b~field2 into table int_table
          from v_a as a 
              inner join v_b as b
               on a~field1 = b~field2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;table emp 
empno name
a sasi
b xxx 
c yyy

table sal
empno salary
a 1000
b 2000


Inner join
****************
select e~empno e~name 
s~sal 
into table int_table
from emp as e
inner join sal
on 
e~empno = s~empno.

if you made inner join between table a and b by emp no 
the selection retrives only if the condition satisfy the output will be

a sasi 1000
b xxx 2000

Outer join
*************************
select e~empno e~name 
s~sal into table  int_table
from emp as e
LEFT OUTER JOIN sal
on 
e~empno = s~empno.

if you made outer join (left /right ) the left table kept as it is the 
if the condition satisfy the right table entries will fetch else leave it blank
the output will be

a sasi a 1000
b xxx b 2000
c yyy&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if hlped mark points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Nov 2006 10:07:35 GMT</pubDate>
    <dc:creator>anversha_s</dc:creator>
    <dc:date>2006-11-07T10:07:35Z</dc:date>
    <item>
      <title>Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703684#M308350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello I need to do something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_a = 'table1'&lt;/P&gt;&lt;P&gt;v_b = 'table2'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select a.field1, b.field2&lt;/P&gt;&lt;P&gt;from (v_a) as a inner join (v_b) as b&lt;/P&gt;&lt;P&gt;    on a.field1 = b.field2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This sentence is giving me an error in the inner join, how can this be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:03:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703684#M308350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703685#M308351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Select a~field1, b~field2 into table itab
          from v_a as a inner join v_b as b
           on a~field1 = b~field2.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:04:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703685#M308351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703686#M308352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do not use a.field1, b.field2. u should not use . or ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use a&lt;SUB&gt;field1 b&lt;/SUB&gt;field2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select a&lt;SUB&gt;field1 b&lt;/SUB&gt;field2&lt;/P&gt;&lt;P&gt;from (v_a) as a inner join (v_b) as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;field1 = b&lt;/SUB&gt;field2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a look at below link for sample code:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_InnerJoinStatement.asp" target="test_blank"&gt;http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_InnerJoinStatement.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Vibha &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Please mark all the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:06:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703686#M308352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703687#M308353</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;chk this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select a~field1, b~field2 into table int_table
          from v_a as a 
              inner join v_b as b
               on a~field1 = b~field2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;table emp 
empno name
a sasi
b xxx 
c yyy

table sal
empno salary
a 1000
b 2000


Inner join
****************
select e~empno e~name 
s~sal 
into table int_table
from emp as e
inner join sal
on 
e~empno = s~empno.

if you made inner join between table a and b by emp no 
the selection retrives only if the condition satisfy the output will be

a sasi 1000
b xxx 2000

Outer join
*************************
select e~empno e~name 
s~sal into table  int_table
from emp as e
LEFT OUTER JOIN sal
on 
e~empno = s~empno.

if you made outer join (left /right ) the left table kept as it is the 
if the condition satisfy the right table entries will fetch else leave it blank
the output will be

a sasi a 1000
b xxx b 2000
c yyy&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if hlped mark points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:07:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703687#M308353</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-07T10:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703688#M308354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and also dont use comma(,)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:08:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703688#M308354</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703689#M308355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry I put dots instead of - (too much java background &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; ) but the instructions I'm looking for needs to read the table names from a table, then pass it to the SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:09:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703689#M308355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703690#M308356</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;select v_a&lt;SUB&gt;field1 v_b&lt;/SUB&gt;field2 &lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;from v_a inner join v_b&lt;/P&gt;&lt;P&gt;on v_a&lt;SUB&gt;field1 = v_b&lt;/SUB&gt;field2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;syntax is as above but it looks meaningless since you are trying to display the same field twice as u r equating the 2 fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check it once&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:12:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703690#M308356</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703691#M308357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I really doubt if this works as the fields can not be determined until runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow have to check myself personally on system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:14:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703691#M308357</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703692#M308358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will try to explain myself better. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name of the tables are in one table. I need to read the table and capture the table names, then pass it to the sql. For example I'm able to do this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_a = 'table1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a-1&lt;/P&gt;&lt;P&gt;FROM (v_a) as a&lt;/P&gt;&lt;P&gt;WHERE ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But apparantely I cannot do this with two tables, something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT ...&lt;/P&gt;&lt;P&gt;FROM (va_a) as a inner join (va_b) as b on ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:17:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703692#M308358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703693#M308359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Scott ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if u like to use dynamic way of assaigning fields, chk this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below is a wonderfull piece of coding were we can dynamically access the table using inner join and without mentioning the field names !!!&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: P_MATNR TYPE MATNR.
 
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA: WERKS LIKE MARC-WERKS,
END OF ITAB.
 
DATA: BEGIN OF DY_FIELDS OCCURS 0,
FIELD(61),
END OF DY_FIELDS.
 

DATA: FIELDS LIKE DFIES OCCURS 0 WITH HEADER LINE.
 
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = 'MARA'
TABLES
DFIES_TAB = FIELDS
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
 
 
LOOP AT FIELDS.
 
CLEAR: DY_FIELDS.
 
CONCATENATE 'A~' FIELDS-FIELDNAME INTO DY_FIELDS-FIELD.
 
APPEND DY_FIELDS.
 
ENDLOOP.
 

DY_FIELDS = 'B~WERKS'.
APPEND DY_FIELDS.
 
SELECT (DY_FIELDS)
INTO TABLE ITAB
FROM MARA AS A INNER JOIN MARC AS B
ON A~MATNR = B~MATNR
WHERE A~MATNR = P_MATNR.
 

CHECK SY-SUBRC = 0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if hlped pls mark points&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:22:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703693#M308359</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-07T10:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703694#M308360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Anversha but I don't see where you use an inner join with two dinnamic tables. I only see how to use the dinamyc fields which is not exactly what I'm looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:28:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703694#M308360</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703695#M308361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Scott&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Have just tried on my system to unvail. &amp;lt;b&amp;gt;Not able to perform the join&amp;lt;/b&amp;gt; statement when any of the table is referenced in a dynamic way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Will try to explore more on this when i get back to office tomorrow. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2006 10:33:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/1703695#M308361</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-07T10:33:23Z</dc:date>
    </item>
  </channel>
</rss>

