<?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: Performance  Multiple JOIN with DISTINCT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691636#M31129</link>
    <description>&lt;P&gt;Dear Matthew,&lt;/P&gt;
  &lt;P&gt;Good morning, thanks for your sharing.&lt;/P&gt;
  &lt;P&gt;Appreciate.&lt;/P&gt;
  &lt;P&gt;Best Regards,&lt;/P&gt;
  &lt;P&gt;Kuan.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2018 12:26:45 GMT</pubDate>
    <dc:creator>kuanchin</dc:creator>
    <dc:date>2018-08-27T12:26:45Z</dc:date>
    <item>
      <title>Performance  Multiple JOIN with DISTINCT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691632#M31125</link>
      <description>&lt;P&gt;Dear ABAP master,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Good morning, currently our SAP system upgraded to :&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; NW FOR S4HANA NW 7.52 FOR S/4HANA 1709&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;SAP_ABAP 75C /SP2&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;For this below coding with DISTINCT and multiple JOIN, will it be consider BAD coding ?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Shall I change it with only JOIN, later use DELETE DUPLICATE ?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;And JOIN with INNER + LEFT OUTER will also impact the performance ?&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    SELECT DISTINCT a~matnr, a~mtart, a~matkl, a~meins , a~lvorm,
           b~werks, b~lgort, b~charg, ( ( b~clabs + b~ceinm ) ) AS quantity,
           c~vfdat, c~zustd, c~lwedt,
           d~maktx,
           e~stprs,
           g~waers,
           h~prgrp,
           h~werks
      FROM mara AS a
      INNER JOIN mchb AS b
         ON a~matnr = b~matnr
      INNER JOIN mch1 AS c
         ON c~matnr = b~matnr
        AND c~charg = b~charg
      LEFT OUTER JOIN makt AS d
         ON d~matnr = a~matnr
      INNER JOIN mbew AS e
         ON e~matnr = a~matnr
         AND e~bwkey = b~werks
      INNER JOIN t001k AS f
         ON f~bwkey = b~werks
      INNER JOIN t001 AS g
         ON g~bukrs = f~bukrs
      LEFT OUTER JOIN pgmi AS h
         ON b~matnr = h~nrmit
        AND b~werks = h~wemit
      WHERE a~matnr IN @it_s_matnr
        AND a~mtart IN @it_s_mtart
        AND a~matkl IN @it_s_matkl
        AND b~lgort IN @it_s_lgort
        AND b~werks EQ @i_werks
        AND c~vfdat LE @( sy-datum + i_days )
        AND c~vfdat NE @l_vfdat
        AND d~spras EQ @gc_en
      INTO TABLE @gt_data .

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Kindly advice.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Very appreciate.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Best Regards,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Kuan.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 02:51:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691632#M31125</guid>
      <dc:creator>kuanchin</dc:creator>
      <dc:date>2018-08-27T02:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Performance  Multiple JOIN with DISTINCT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691633#M31126</link>
      <description>&lt;P&gt;When you paste code, please use right-click "paste as plain text". In this way, you don't get the HTML tags pasted. I've edited it for you this time.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 06:38:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691633#M31126</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-08-27T06:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Performance  Multiple JOIN with DISTINCT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691634#M31127</link>
      <description>&lt;P&gt;As a general principle, making the database do the work is preferable to doing it in ABAP. So, as long as your query is producing the right results, it's fine.&lt;/P&gt;
  &lt;P&gt;However, you shouldn't use the &lt;STRONG&gt;AS &lt;/STRONG&gt;structure. Like &lt;STRONG&gt;AS a&lt;/STRONG&gt; and &lt;STRONG&gt;a~matnr&lt;/STRONG&gt;. It is easier to understand and clearer which field comes from where if you omit the &lt;STRONG&gt;AS &lt;/STRONG&gt;and use the name of the table directly. &lt;STRONG&gt;mara~matnr&lt;/STRONG&gt;. &lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 06:45:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691634#M31127</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-08-27T06:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Performance  Multiple JOIN with DISTINCT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691635#M31128</link>
      <description>&lt;P&gt;Dear Matthew,&lt;/P&gt;
  &lt;P&gt;Good morning, note with thanks.&lt;/P&gt;
  &lt;P&gt;Many thanks for your guidance.&lt;/P&gt;
  &lt;P&gt;Best Regards,&lt;/P&gt;
  &lt;P&gt;Kuan.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 12:25:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691635#M31128</guid>
      <dc:creator>kuanchin</dc:creator>
      <dc:date>2018-08-27T12:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Performance  Multiple JOIN with DISTINCT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691636#M31129</link>
      <description>&lt;P&gt;Dear Matthew,&lt;/P&gt;
  &lt;P&gt;Good morning, thanks for your sharing.&lt;/P&gt;
  &lt;P&gt;Appreciate.&lt;/P&gt;
  &lt;P&gt;Best Regards,&lt;/P&gt;
  &lt;P&gt;Kuan.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 12:26:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-multiple-join-with-distinct/m-p/691636#M31129</guid>
      <dc:creator>kuanchin</dc:creator>
      <dc:date>2018-08-27T12:26:45Z</dc:date>
    </item>
  </channel>
</rss>

