<?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/2755533#M641179</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check these threads out...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4009521"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3935566"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3676534"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful,&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Sep 2007 10:03:08 GMT</pubDate>
    <dc:creator>former_member189629</dc:creator>
    <dc:date>2007-09-11T10:03:08Z</dc:date>
    <item>
      <title>JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755524#M641170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   I need example of all types of joins&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 09:55:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755524#M641170</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T09:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755525#M641171</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;go through these links&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/EN/50/a71ec8f65911d296390000e82de14a/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/EN/50/a71ec8f65911d296390000e82de14a/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 09:57:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755525#M641171</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T09:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755526#M641172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;b&amp;gt;inner join&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a~pernr&lt;/P&gt;&lt;P&gt;a~bukrs&lt;/P&gt;&lt;P&gt;b~vorna&lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;from pa0001 as a join pa0002 as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;pernr = b&lt;/SUB&gt;pernr&lt;/P&gt;&lt;P&gt;where pernr in s_pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vasu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 09:59:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755526#M641172</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T09:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755527#M641173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;go to transaction ABAPDOCU&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 09:59:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755527#M641173</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T09:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755528#M641174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Inner join&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF p_bsart IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT  ekko~bukrs&lt;/P&gt;&lt;P&gt;            ekko~lifnr&lt;/P&gt;&lt;P&gt;            ekko~ebeln&lt;/P&gt;&lt;P&gt;            ekko~waers&lt;/P&gt;&lt;P&gt;            ekko~bsart&lt;/P&gt;&lt;P&gt;            ekko~ekorg&lt;/P&gt;&lt;P&gt;            ekko~ekgrp&lt;/P&gt;&lt;P&gt;            ekpo~ebelp&lt;/P&gt;&lt;P&gt;            ekpo~txz01&lt;/P&gt;&lt;P&gt;            ekpo~matnr&lt;/P&gt;&lt;P&gt;            ekpo~werks&lt;/P&gt;&lt;P&gt;            ekpo~menge&lt;/P&gt;&lt;P&gt;            ekpo~meins&lt;/P&gt;&lt;P&gt;            ekpo~netpr&lt;/P&gt;&lt;P&gt;            ekpo~netwr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            INTO TABLE  t_itab1 FROM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            ekko INNER JOIN ekpo ON ekko&lt;SUB&gt;ebeln = ekpo&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;            WHERE    ekko~ebeln IN s_ebeln  AND&lt;/P&gt;&lt;P&gt;                     ekko~bukrs IN s_bukrs  AND&lt;/P&gt;&lt;P&gt;                     ekko~lifnr IN s_lifnr  AND&lt;/P&gt;&lt;P&gt;                     ekko~ekorg IN s_ekorg  AND&lt;/P&gt;&lt;P&gt;                     ekko~ekgrp IN s_ekgrp  AND&lt;/P&gt;&lt;P&gt;                     ekpo~matnr IN s_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The difference between an INNER JOIN and an OUTER JOIN is the following. If a query on an INNER JOIN of VBAK (outer table) and VBAP (inner table) finds a record in VBAK but no matching records in VBAP, then no data is retrieved from the database because the inner table is empty. If you still want to keep VBAK rows for which there are no matching VBAP rows, you need to use the OUTER JOIN construct available in ABAP/4 Open SQL in 4.x..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi&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;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;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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 09:59:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755528#M641174</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T09:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755529#M641175</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;check this thread...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3239605"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Alfred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:00:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755529#M641175</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755530#M641176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;INNER JOIN results are an intersection of the tables being joined where in only if both the tables havethe data the result is pused onto the result set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE as in LEFT OUTR JOIN you can push the data of the LEF T table on the resultset even when the join condition is not met.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The use is that you wantto have all the data that is there in left table and also the right table if the join condition is a success then right table fileds will have data else they are initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OUTJOIN's are used in MAINTENANNCE VIEWS, HELP VIEWS .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INNER JOINS are used DATABSE VIEWS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:01:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755530#M641176</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755531#M641177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use select statement with for ALL ENTRIES OPTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the majority of cases inner joins will actually be the requirement, but in the minority of cases you will want to use an outer join. Outer joins are useful where you may need all records from a certain table, that meet the selection criteria, and all data from another table(s), IF it exists. But if the latter data does not exist, you still want to get the first table data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using outer joins places a heavy load on the database engine (although no heavier that if you coded a nested select), so be very parsimonious about the use of outer joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The performance of the join depends on the database optimizer used especially if there are more than two tables used for joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to give maximum number of conditions in the ON clause. This is because the ON conditions are evaluated first and the virtual table created as a result is the one on which the WHERE clause applies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use subqueries if possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure you follow this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consolidated selections&lt;/P&gt;&lt;P&gt;No row by row processing&lt;/P&gt;&lt;P&gt;No check statements&lt;/P&gt;&lt;P&gt;No selections within loops&lt;/P&gt;&lt;P&gt;Selections are 'into' internal tables - no appends&lt;/P&gt;&lt;P&gt;SQL trace check completed&lt;/P&gt;&lt;P&gt;All programs checked to make sure that they are using the full index and in the &lt;/P&gt;&lt;P&gt;Correct order.&lt;/P&gt;&lt;P&gt;Minimum or zero number of identical selects.&lt;/P&gt;&lt;P&gt;Use of appropriate Indexes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this code for your problem .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A real life scenario that has been optimized.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data : 	Begin of  I_vbak occurs 0,&lt;/P&gt;&lt;P&gt;Vbeln like vbak-vbeln,&lt;/P&gt;&lt;P&gt;End of I_vbak.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Data :	Begin I_vbap occurs 0,&lt;/P&gt;&lt;P&gt;          	Vbeln like vbap-vbeln,&lt;/P&gt;&lt;P&gt;           	Posnr like vbap-posnr,&lt;/P&gt;&lt;P&gt;           	Matnr like vbap-matnr,&lt;/P&gt;&lt;P&gt;           	Kwmeng like vbap-kwmeng,&lt;/P&gt;&lt;P&gt;End of I_vbap.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Data :	Begin of I_makt occurs 0,&lt;/P&gt;&lt;P&gt;Matnr like makt-matnr,&lt;/P&gt;&lt;P&gt;Maktx like makt-maktx,&lt;/P&gt;&lt;P&gt;End of  I_makt.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Data :	d_lines like sy-subrc.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Start-of-selection.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Refresh : I_vbak , I_vbap , I_makt.&lt;/P&gt;&lt;P&gt;Select vbeln from VBAK into table I_vbak&lt;/P&gt;&lt;P&gt;Where erdat = p_erdat   And&lt;/P&gt;&lt;P&gt;vkorg = p_vkorg  And&lt;/P&gt;&lt;P&gt;vtweg = p_vtweg And&lt;/P&gt;&lt;P&gt;spart = p_spart.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Clear d_lines.&lt;/P&gt;&lt;P&gt;Describe table I_vbak lines d_lines.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Check d_lines &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Select vbeln posnr matnr kwmeng from VBAP into table I_vbap&lt;/P&gt;&lt;P&gt;For all entries in table I_vbak&lt;/P&gt;&lt;P&gt;Where vbeln = I_vbak-vbeln.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Clear d_lines.&lt;/P&gt;&lt;P&gt;Describe table I_vbap lines d_lines.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Check d_lines &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;End-of-selection.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Sort I_vbap by vbeln matnr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Select matnr maktx from makt into I_makt&lt;/P&gt;&lt;P&gt;For all entries in I_vbap&lt;/P&gt;&lt;P&gt;Where spras = sy-langu And&lt;/P&gt;&lt;P&gt;matnr = I_vbap-matnr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Sort I_makt by matnr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Loop at I_vbap.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      Clear I_makt.&lt;/P&gt;&lt;P&gt;      Read I_makt with key matnr = I_vbap-matnr binary search.&lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;P&gt;      Write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; I_vbnap-vbeln,&lt;/P&gt;&lt;P&gt;                   I_vbap-psonr,&lt;/P&gt;&lt;P&gt;                   I_vbap-matnr,&lt;/P&gt;&lt;P&gt;                   I_Makt-matnr,&lt;/P&gt;&lt;P&gt;                   I_vbap-kwmeng.&lt;/P&gt;&lt;P&gt; &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;&lt;/P&gt;&lt;P&gt;Reward points if helpful .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revert back for more help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:02:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755531#M641177</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755532#M641178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;u&amp;gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:02:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755532#M641178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755533#M641179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check these threads out...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4009521"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3935566"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3676534"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful,&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:03:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755533#M641179</guid>
      <dc:creator>former_member189629</dc:creator>
      <dc:date>2007-09-11T10:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755534#M641180</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;&amp;lt;b&amp;gt;&amp;lt;u&amp;gt;Inner Join:-&amp;lt;/u&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;SELECT  p&lt;SUB&gt;carrid p&lt;/SUB&gt;connid f&lt;SUB&gt;fldate b&lt;/SUB&gt;bookid&lt;/P&gt;&lt;P&gt;  INTO  CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;  FROM  ( ( spfli AS p&lt;/P&gt;&lt;P&gt;            INNER JOIN sflight AS f ON p&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;                                       p&lt;SUB&gt;connid = f&lt;/SUB&gt;connid    )&lt;/P&gt;&lt;P&gt;            INNER JOIN sbook   AS b ON b&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;                                       b&lt;SUB&gt;connid = f&lt;/SUB&gt;connid AND&lt;/P&gt;&lt;P&gt;                                       b&lt;SUB&gt;fldate = f&lt;/SUB&gt;fldate     )&lt;/P&gt;&lt;P&gt;  WHERE p~cityfrom = 'FRANKFURT' AND&lt;/P&gt;&lt;P&gt;        p~cityto   = 'NEW YORK'  AND&lt;/P&gt;&lt;P&gt;        f&lt;SUB&gt;seatsmax &amp;gt; f&lt;/SUB&gt;seatsocc.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Left Outer Join&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;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 AND&lt;/P&gt;&lt;P&gt;                                     p~cityfrom = 'FRANKFURT'.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enjoy SAP.&lt;/P&gt;&lt;P&gt;Pankaj Singh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755534#M641180</guid>
      <dc:creator>messier31</dc:creator>
      <dc:date>2007-09-11T10:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: JOINS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755535#M641181</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;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Inner join:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_inner_join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa,&lt;/P&gt;&lt;P&gt;        carrid TYPE spfli-carrid,&lt;/P&gt;&lt;P&gt;        connid TYPE spfli-connid,&lt;/P&gt;&lt;P&gt;        fldate TYPE sflight-fldate,&lt;/P&gt;&lt;P&gt;        bookid TYPE sbook-bookid,&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 UNIQUE KEY carrid connid fldate bookid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  p&lt;SUB&gt;carrid p&lt;/SUB&gt;connid f&lt;SUB&gt;fldate b&lt;/SUB&gt;bookid&lt;/P&gt;&lt;P&gt;  INTO  CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;  FROM  ( ( spfli AS p&lt;/P&gt;&lt;P&gt;            INNER JOIN sflight AS f ON p&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;                                       p&lt;SUB&gt;connid = f&lt;/SUB&gt;connid    )&lt;/P&gt;&lt;P&gt;            INNER JOIN sbook   AS b ON b&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;                                       b&lt;SUB&gt;connid = f&lt;/SUB&gt;connid AND&lt;/P&gt;&lt;P&gt;                                       b&lt;SUB&gt;fldate = f&lt;/SUB&gt;fldate     )&lt;/P&gt;&lt;P&gt;  WHERE p~cityfrom = 'FRANKFURT' AND&lt;/P&gt;&lt;P&gt;        p~cityto   = 'NEW YORK'  AND&lt;/P&gt;&lt;P&gt;        f&lt;SUB&gt;seatsmax &amp;gt; f&lt;/SUB&gt;seatsocc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa.&lt;/P&gt;&lt;P&gt;  AT NEW fldate.&lt;/P&gt;&lt;P&gt;    WRITE: / wa-carrid, wa-connid, wa-fldate.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;  WRITE / wa-bookid.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example links the columns CARRID, CONNID, FLDATE, and BOOKID of the table SPFLI, SFLIGHT, and SBOOK, and creates a list of booking numbers for all flights from Frankfurt to New York that are not fully booked. An alias name is assigned to each table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Left outer join:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_left_outer_join.&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 AND&lt;/P&gt;&lt;P&gt;                                     p~cityfrom = 'FRANKFURT'.&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-carrid, wa-carrname, wa-connid.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;3 tables inner join:&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Select single Vbrk&lt;SUB&gt;Bukrs Vbrk&lt;/SUB&gt;Kunrg    Vbrk~Vbeln  &lt;/P&gt;&lt;P&gt;                   Vbrk&lt;SUB&gt;Fkdat Vbrk&lt;/SUB&gt;Bstnk_Vf Vbrk~Zterm  &lt;/P&gt;&lt;P&gt;                   Tvzbt~Vtext  &lt;/P&gt;&lt;P&gt;                   Vbak&lt;SUB&gt;Vbeln Vbak&lt;/SUB&gt;Bstdk  &lt;/P&gt;&lt;P&gt;                   Likp&lt;SUB&gt;Vbeln Likp&lt;/SUB&gt;lfdat    Likp~Lfuhr  &lt;/P&gt;&lt;P&gt;       into w_vbrk  &lt;/P&gt;&lt;P&gt;       from vbrk  &lt;/P&gt;&lt;P&gt;      inner join       Tvzbt on Tvzbt&lt;SUB&gt;Zterm        = Vbrk&lt;/SUB&gt;Zterm      and  &lt;/P&gt;&lt;P&gt;                                Tvzbt~Spras        = sy-langu  &lt;/P&gt;&lt;P&gt;      Inner join       Vbfa  as SalesLnk  &lt;/P&gt;&lt;P&gt;                             on SalesLnk~vbeln     = pu_vbeln        and  &lt;/P&gt;&lt;P&gt;                                SalesLnk~vbtyp_v   = c_order  &lt;/P&gt;&lt;P&gt;            inner join Vbak  on Vbak&lt;SUB&gt;Vbeln           = SalesLnk&lt;/SUB&gt;Vbelv &lt;/P&gt;&lt;P&gt;      Inner join       Vbfa  as DeliveryLnk  &lt;/P&gt;&lt;P&gt;                             on DeliveryLnk~vbeln   = pu_vbeln       and  &lt;/P&gt;&lt;P&gt;                                DeliveryLnk~vbtyp_v = c_Delivery  &lt;/P&gt;&lt;P&gt;            inner join Likp  on Likp&lt;SUB&gt;Vbeln          = DeliveryLnk&lt;/SUB&gt;Vbelv  &lt;/P&gt;&lt;P&gt;      where vbrk~vbeln = pu_Vbeln.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:08:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/2755535#M641181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:08:14Z</dc:date>
    </item>
  </channel>
</rss>

