<?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 : Three tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203607#M471114</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi S V,&lt;/P&gt;&lt;P&gt;           Yes .it is  possible to use  INNER JOIN  between three tables &lt;/P&gt;&lt;P&gt;Refer this code : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;matnr  a&lt;/SUB&gt;mEINS a&lt;SUB&gt;MTART D&lt;/SUB&gt;MAKTx b&lt;SUB&gt;werks c&lt;/SUB&gt;lgort c~labst INTO CORRESPONDING FIELDS OF TABLE IT_MATERIAL&lt;/P&gt;&lt;P&gt;                              FROM mara AS a&lt;/P&gt;&lt;P&gt;                              INNER JOIN MAKT AS D on a&lt;SUB&gt;matnr = d&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                              inner join marc AS b&lt;/P&gt;&lt;P&gt;                              ON a&lt;SUB&gt;matnr = b&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                              inner join MARD as c&lt;/P&gt;&lt;P&gt;                              ON B&lt;SUB&gt;MATNR = C&lt;/SUB&gt;MATNR AND B&lt;SUB&gt;WERKS = C&lt;/SUB&gt;WERKS&lt;/P&gt;&lt;P&gt;                             where A&lt;SUB&gt;MATNR IN S_MATNR and b&lt;/SUB&gt;werks in s_werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if helpful.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hemant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 May 2007 05:58:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-08T05:58:55Z</dc:date>
    <item>
      <title>INNER JOIN : Three tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203604#M471111</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;I have a query that selects among other fields MSEG-MATNR by INNER JOIN of MKPF (header of material document) and MSEG(line item detail) on           mkpf&lt;SUB&gt;mandt = mseg&lt;/SUB&gt;mandt&lt;/P&gt;&lt;P&gt;and mkpf&lt;SUB&gt;mblnr = mseg&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;and mkpf&lt;SUB&gt;mjahr = mseg&lt;/SUB&gt;mjahr&lt;/P&gt;&lt;P&gt;.This query is part of a report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to include the old material number (MARA-BISMT) in the selection criteria and ALV report display depending on the material number (key field MARA-MATNR). MARA-MATNR is a key field in MARA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to use the INNER JOIN here between three tables MARA/MSEG/MKPF here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALso what changes should I make to field catalog and FM REUSE_ALV_GRID_DISPLAY..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 05:53:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203604#M471111</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T05:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN : Three tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203605#M471112</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;Good Check the following documentation which may be helpful,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;INNER JOIN&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;One or more lines on the right-hand table is linked to a line in the&lt;/P&gt;&lt;P&gt;left-hand table. Lines from the left-handed table&lt;/P&gt;&lt;P&gt;is only selected if they meet the ON criteria.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                   FROM from vbak as a inner join vbap as b&lt;/P&gt;&lt;P&gt;                             ON b&lt;SUB&gt;vbeln = a&lt;/SUB&gt;vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One or more lines from vbap is selected for each line in vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Limits on the ON clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck and thanks&lt;/P&gt;&lt;P&gt;AK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 05:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203605#M471112</guid>
      <dc:creator>ashok_kumar24</dc:creator>
      <dc:date>2007-05-08T05:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN : Three tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203606#M471113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;yes you can join MARA table as a join with MSEG&lt;/P&gt;&lt;P&gt;usiong mseg&lt;SUB&gt;matnr = mara&lt;/SUB&gt;matnr along with MKPF&lt;/P&gt;&lt;P&gt;Add the old material number field which is fetched from mara in the field catalog internal table and populate and display.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 05:56:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203606#M471113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T05:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN : Three tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203607#M471114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi S V,&lt;/P&gt;&lt;P&gt;           Yes .it is  possible to use  INNER JOIN  between three tables &lt;/P&gt;&lt;P&gt;Refer this code : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;matnr  a&lt;/SUB&gt;mEINS a&lt;SUB&gt;MTART D&lt;/SUB&gt;MAKTx b&lt;SUB&gt;werks c&lt;/SUB&gt;lgort c~labst INTO CORRESPONDING FIELDS OF TABLE IT_MATERIAL&lt;/P&gt;&lt;P&gt;                              FROM mara AS a&lt;/P&gt;&lt;P&gt;                              INNER JOIN MAKT AS D on a&lt;SUB&gt;matnr = d&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                              inner join marc AS b&lt;/P&gt;&lt;P&gt;                              ON a&lt;SUB&gt;matnr = b&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;                              inner join MARD as c&lt;/P&gt;&lt;P&gt;                              ON B&lt;SUB&gt;MATNR = C&lt;/SUB&gt;MATNR AND B&lt;SUB&gt;WERKS = C&lt;/SUB&gt;WERKS&lt;/P&gt;&lt;P&gt;                             where A&lt;SUB&gt;MATNR IN S_MATNR and b&lt;/SUB&gt;werks in s_werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if helpful.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hemant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 05:58:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203607#M471114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-08T05:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN : Three tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203608#M471115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SV , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... [(] {dbtab_left [AS tabalias_left]} | join &lt;/P&gt;&lt;P&gt;{[INNER] JOIN}|{LEFT [OUTER] JOIN} &lt;/P&gt;&lt;P&gt;{dbtab_right [AS tabalias_right] ON join_cond} [)] ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least one comparison must be specified after ON. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Individual comparisons may be joined using AND only. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following language elements may not be used: BETWEEN, LIKE, IN. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No sub-queries may be used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For outer joins, only equality comparisons (=, EQ) are possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for inner join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for outer join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_cityfr TYPE spfli-cityfrom, &lt;/P&gt;&lt;P&gt;p_cityto TYPE spfli-cityto. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;fldate TYPE sflight-fldate, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY fldate carrname connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT c&lt;SUB&gt;carrname p&lt;/SUB&gt;connid f~fldate &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM ( ( scarr AS c &lt;/P&gt;&lt;P&gt;INNER JOIN spfli AS p ON p&lt;SUB&gt;carrid = c&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr &lt;/P&gt;&lt;P&gt;AND p~cityto = p_cityto ) &lt;/P&gt;&lt;P&gt;INNER JOIN sflight AS f ON f&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND f&lt;SUB&gt;connid = p&lt;/SUB&gt;connid ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;WRITE: / wa-fldate, wa-carrname, wa-connid. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS p_cityfr TYPE spfli-cityfrom. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;carrid TYPE scarr-carrid, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa, &lt;/P&gt;&lt;P&gt;itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH NON-UNIQUE KEY carrid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT s&lt;SUB&gt;carrid s&lt;/SUB&gt;carrname p~connid &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM scarr AS s &lt;/P&gt;&lt;P&gt;LEFT OUTER JOIN spfli AS p ON s&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;IF wa-connid = '0000'. &lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-carrname. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we r using 2 type of joins in abap they are&lt;/P&gt;&lt;P&gt;1) inner join.&lt;/P&gt;&lt;P&gt;this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after innerjoining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;1 2 3 5&lt;/P&gt;&lt;P&gt;only common field is taken..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)left outer join&lt;/P&gt;&lt;P&gt;here it wil work in opossite way it will give values whic are not common&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after left outer joining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;2 3 4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;only fields which are not common is taken from the left table..other field(d here) wil be empty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it will help u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;Reward Points if helpful.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Check for ALVROBOT.COM also it is also helpful.&amp;lt;/b&amp;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;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amber S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2007 05:59:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join-three-tables/m-p/2203608#M471115</guid>
      <dc:creator>former_member198270</dc:creator>
      <dc:date>2007-05-08T05:59:04Z</dc:date>
    </item>
  </channel>
</rss>

