<?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: Help with INNER JOIN in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688649#M302886</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried to run SQL trace for your program to see why this select takes so long ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would rather select from MKPF &amp;amp; MSEG via join and then select other data from t001w &amp;amp; T156T. In this case you can put some logic to access T001w &amp;amp; T156T just to retrieve data for already selected plants/movement types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides, it really helps optimizer to chose right access path if you keep your select statements simple &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Oct 2006 18:27:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-23T18:27:46Z</dc:date>
    <item>
      <title>Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688647#M302884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following statement takes quite a long time to run. Any suggestions how it can be fine tuned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT MSEG&lt;SUB&gt;WERKS MSEG&lt;/SUB&gt;BWART MKPF&lt;SUB&gt;BUDAT MKPF&lt;/SUB&gt;BLDAT&lt;/P&gt;&lt;P&gt;         MKPF&lt;SUB&gt;BKTXT MKPF&lt;/SUB&gt;MBLNR MSEG&lt;SUB&gt;GRUND MSEG&lt;/SUB&gt;LGORT&lt;/P&gt;&lt;P&gt;         MSEG&lt;SUB&gt;MATNR MSEG&lt;/SUB&gt;MENGE MSEG&lt;SUB&gt;UMLGO MSEG&lt;/SUB&gt;SGTXT&lt;/P&gt;&lt;P&gt;         MSEG&lt;SUB&gt;CHARG T156T&lt;/SUB&gt;BTEXT T001W&lt;SUB&gt;SPRAS MSEG&lt;/SUB&gt;CHARG&lt;/P&gt;&lt;P&gt;         MSEG&lt;SUB&gt;SHKZG MKPF&lt;/SUB&gt;CPUTM                   &lt;/P&gt;&lt;P&gt;    INTO TABLE T_OUTPUT&lt;/P&gt;&lt;P&gt;    FROM MKPF&lt;/P&gt;&lt;P&gt;    INNER JOIN MSEG&lt;/P&gt;&lt;P&gt;       ON 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;    INNER JOIN T001W&lt;/P&gt;&lt;P&gt;       ON MSEG&lt;SUB&gt;WERKS = T001W&lt;/SUB&gt;WERKS&lt;/P&gt;&lt;P&gt;    INNER JOIN T156T&lt;/P&gt;&lt;P&gt;       ON MSEG&lt;SUB&gt;BWART = T156T&lt;/SUB&gt;BWART&lt;/P&gt;&lt;P&gt;       AND MSEG&lt;SUB&gt;SOBKZ = T156T&lt;/SUB&gt;SOBKZ&lt;/P&gt;&lt;P&gt;       AND MSEG&lt;SUB&gt;KZBEW = T156T&lt;/SUB&gt;KZBEW&lt;/P&gt;&lt;P&gt;       AND MSEG&lt;SUB&gt;KZZUG = T156T&lt;/SUB&gt;KZZUG&lt;/P&gt;&lt;P&gt;       AND MSEG&lt;SUB&gt;KZVBR = T156T&lt;/SUB&gt;KZVBR&lt;/P&gt;&lt;P&gt;    WHERE MKPF~BUDAT IN S_BUDAT&lt;/P&gt;&lt;P&gt;      AND MSEG~WERKS EQ P_WERKS&lt;/P&gt;&lt;P&gt;      AND MSEG~XAUTO NE 'X'&lt;/P&gt;&lt;P&gt;      AND MSEG~BWART IN S_BWART&lt;/P&gt;&lt;P&gt;      AND MSEG~MATNR IN S_MATNR&lt;/P&gt;&lt;P&gt;      AND T156T~SPRAS EQ SY-LANGU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Brain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 18:05:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688647#M302884</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T18:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688648#M302885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can start by making sure that S_MATNR is not empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might also try some re-arranging:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT mseg~werks mseg~bwart mkpf~budat mkpf~bldat
         mkpf~bktxt mkpf~mblnr mseg~grund mseg~lgort
         mseg~matnr mseg~menge mseg~umlgo mseg~sgtxt
         mseg~charg t156t~btext t001w~spras mseg~charg
         mseg~shkzg mkpf~cputm
    INTO TABLE t_output

    FROM mseg
    INNER JOIN mkpf
       ON mkpf~mblnr = mseg~mblnr
      AND mkpf~mjahr = mseg~mjahr
    INNER JOIN t001w
       ON t001w~werks = mseg~werks
    INNER JOIN t156t
       ON  t156t~bwart = mseg~bwart
       AND t156t~sobkz = mseg~sobkz
       AND t156t~kzbew = mseg~kzbew
       AND t156t~kzzug = mseg~kzzug
       AND t156t~kzvbr = mseg~kzvbr
    WHERE mseg~matnr IN s_matnr
      AND mseg~werks EQ p_werks
      AND mseg~xauto NE 'X'
      AND mseg~bwart IN s_bwart
      AND mkpf~budat IN s_budat
      AND t156t~spras EQ sy-langu.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rob Burbank&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 18:23:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688648#M302885</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T18:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688649#M302886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried to run SQL trace for your program to see why this select takes so long ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would rather select from MKPF &amp;amp; MSEG via join and then select other data from t001w &amp;amp; T156T. In this case you can put some logic to access T001w &amp;amp; T156T just to retrieve data for already selected plants/movement types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides, it really helps optimizer to chose right access path if you keep your select statements simple &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 18:27:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688649#M302886</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T18:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688650#M302887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However usually S_MATNR is not given.&lt;/P&gt;&lt;P&gt;So basically the plant and the Date are the only parameters given.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgarding the splitting up of the inner join, i ll give it a shot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other suggestions....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Brain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 18:42:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688650#M302887</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T18:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688651#M302888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then you will not be able to use an index and it will be slow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 18:51:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688651#M302888</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T18:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688652#M302889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think there is an index on BUDAT in MKPF.&lt;/P&gt;&lt;P&gt;Would be great if this select with join uses this index.&lt;/P&gt;&lt;P&gt;That is why I think it would be easier for optimizer to select right path if join is limited to MKPF/MSEG only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR if even MKPF/MSEG join does not use index - select from MKPF into internal table, then select from MSEG/T001W/T...  using join if necessary, as this join will be by primary keys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 19:19:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-inner-join/m-p/1688652#M302889</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T19:19:42Z</dc:date>
    </item>
  </channel>
</rss>

