<?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: Problem in Inner Join in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256086#M1528263</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;PRE&gt;&lt;CODE&gt;SELECT 
  AFKO~FTRMI
  AFKO~AUFNR            
  AFPO~MATNR            
  MAKT~MAKTX            
  AFPO~PSMNG            
  AFPO~WEMNG            
  MARA~MTART            
  MSEG~CHARG            
  MARA~MATKL            
  MARA~SPART            
  RESB~BWART            
  RESB~CHARG            
  RESB~MATNR            
  MSEG~BWART            
  RESB~BDMNG            
  INTO CORRESPONDING FIELDS OF TABLE ITAB "always use CORRESPONDING FIELDS!!!
  FROM AFKO
  INNER JOIN AFPO ON AFKO~AUFNR = AFPO~AUFNR
  INNER JOIN MARA ON AFPO~MATNR = MARA~MATNR
  INNER JOIN MAKT ON MARA~MATNR = MAKT~MATNR
  INNER JOIN MSEG ON AFPO~MATNR = MSEG~MATNR AND 
                     AFKO~AUFNR = MSEG~AUFNR AND 
                     AFPO~DWERK = MSEG~WERKS
  INNER JOIN RESB ON AFKO~AUFNR = RESB~AUFNR AND 
                     MSEG~AUFNR = RESB~AUFNR AND 
                     RESB~RSNUM = AFKO~RSNUM AND 
                     RESB~WERKS = MSEG~WERKS AND 
                     RESB~BAUGR = MSEG~MATNR
  INNER JOIN MARA AS C1 ON RESB~MATNR = C1~MATNR
  WHERE AFKO~FTRMI IN S_DATE 
    AND AFKO~AUFNR IN S_AUFNR 
    AND MARA~MTART IN S_TYPE 
    AND MARA~MATKL = 'T'
    AND RESB~BWART = '261' 
    AND MSEG~BWART = '101'
    AND RESB~XWAOK = 'X' 
    AND AFPO~DWERK = '2000'
    AND RESB~XLOEK EQ SPACE 
    AND MSEG~KZBEW = 'F' 
    AND MAKT~SPRAS = 'E' 
    AND RESB~KZEAR = 'X' 
    AND MARA~MATNR IN S_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You need no AS alias except you join the same table twice, it helps only non-readability.&lt;/P&gt;&lt;P&gt;I think field AUFPS is missing in the join of MSEG and RESB, this may help. You should add MATNR as well because then the index RESB~M will be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Clemens Li on Sep 4, 2010 10:20 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 Sep 2010 20:18:25 GMT</pubDate>
    <dc:creator>Clemenss</dc:creator>
    <dc:date>2010-09-04T20:18:25Z</dc:date>
    <item>
      <title>Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256082#M1528259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT A~FTRMI
              A~AUFNR
              B~MATNR
              D~MAKTX
              B~PSMNG
              B~WEMNG
              C~MTART
              E~CHARG
              C~MATKL
              C~SPART
              R~BWART
              R~CHARG
              R~MATNR
              E~BWART
              R~BDMNG
        INTO TABLE ITAB
        FROM AFKO AS A INNER JOIN AFPO AS B ON A~AUFNR = B~AUFNR
                       INNER JOIN MARA AS C ON B~MATNR = C~MATNR
                       INNER JOIN MAKT AS D ON C~MATNR = D~MATNR
                       INNER JOIN MSEG AS E ON B~MATNR = E~MATNR AND A~AUFNR = E~AUFNR AND B~DWERK = E~WERKS
                       INNER JOIN RESB AS R ON A~AUFNR = R~AUFNR AND E~AUFNR = R~AUFNR AND R~RSNUM = A~RSNUM
                                                                 AND R~WERKS = E~WERKS AND R~BAUGR = E~MATNR
                       INNER JOIN MARA AS C1 ON R~MATNR = C1~MATNR
        WHERE A~FTRMI IN S_DATE AND A~AUFNR IN S_AUFNR AND C~MTART IN S_TYPE AND C~MATKL = 'T'
        AND R~BWART ='261' AND E~BWART = '101'
        AND R~XWAOK ='X' AND B~DWERK = '2000'
        AND R~XLOEK EQ SPACE AND E~KZBEW ='F' AND D~SPRAS = 'E' AND R~KZEAR = 'X' AND C~MATNR IN S_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This query is giving repetative records from RESB table. It combines each line of RESB with the other lines. Can anybody pls tell me is there any field remaining in join condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls Help. &lt;STRONG&gt;&amp;lt;&amp;lt;removed by moderator&amp;gt;&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Swati Ghadge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: kishan P on Sep 4, 2010 9:34 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Sep 2010 02:49:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256082#M1528259</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-04T02:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256083#M1528260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT A~FTRMI&lt;/P&gt;&lt;P&gt;              A~AUFNR&lt;/P&gt;&lt;P&gt;              B~MATNR&lt;/P&gt;&lt;P&gt;              D~MAKTX&lt;/P&gt;&lt;P&gt;              B~PSMNG&lt;/P&gt;&lt;P&gt;              B~WEMNG&lt;/P&gt;&lt;P&gt;              C~MTART&lt;/P&gt;&lt;P&gt;              E~CHARG&lt;/P&gt;&lt;P&gt;              C~MATKL&lt;/P&gt;&lt;P&gt;              C~SPART&lt;/P&gt;&lt;P&gt;              R~BWART&lt;/P&gt;&lt;P&gt;              R~CHARG&lt;/P&gt;&lt;P&gt;              R~MATNR&lt;/P&gt;&lt;P&gt;              E~BWART&lt;/P&gt;&lt;P&gt;              R~BDMNG&lt;/P&gt;&lt;P&gt;        INTO TABLE ITAB&lt;/P&gt;&lt;P&gt;        FROM AFKO AS A INNER JOIN AFPO AS B ON A&lt;SUB&gt;AUFNR = B&lt;/SUB&gt;AUFNR&lt;/P&gt;&lt;P&gt;                       INNER JOIN MARA AS C ON B&lt;SUB&gt;MATNR = C&lt;/SUB&gt;MATNR&lt;/P&gt;&lt;P&gt;                       INNER JOIN MAKT AS D ON C&lt;SUB&gt;MATNR = D&lt;/SUB&gt;MATNR&lt;/P&gt;&lt;P&gt;                       INNER JOIN MSEG AS E ON B&lt;SUB&gt;MATNR = E&lt;/SUB&gt;MATNR AND A&lt;SUB&gt;AUFNR = E&lt;/SUB&gt;AUFNR AND B&lt;SUB&gt;DWERK = E&lt;/SUB&gt;WERKS&lt;/P&gt;&lt;P&gt;                       INNER JOIN RESB AS R ON A&lt;SUB&gt;AUFNR = R&lt;/SUB&gt;AUFNR AND E&lt;SUB&gt;AUFNR = R&lt;/SUB&gt;AUFNR AND R&lt;SUB&gt;RSNUM = A&lt;/SUB&gt;RSNUM&lt;/P&gt;&lt;P&gt;                                                                 AND R&lt;SUB&gt;WERKS = E&lt;/SUB&gt;WERKS AND R&lt;SUB&gt;BAUGR = E&lt;/SUB&gt;MATNR&lt;/P&gt;&lt;P&gt;                       INNER JOIN MARA AS C1 ON R&lt;SUB&gt;MATNR = C1&lt;/SUB&gt;MATNR&lt;/P&gt;&lt;P&gt;        WHERE A&lt;SUB&gt;FTRMI IN S_DATE AND A&lt;/SUB&gt;AUFNR IN S_AUFNR AND C&lt;SUB&gt;MTART IN S_TYPE AND C&lt;/SUB&gt;MATKL = 'T'&lt;/P&gt;&lt;P&gt;        AND R&lt;SUB&gt;BWART ='261' AND E&lt;/SUB&gt;BWART = '101'&lt;/P&gt;&lt;P&gt;        AND R&lt;SUB&gt;XWAOK ='X' AND B&lt;/SUB&gt;DWERK = '2000'&lt;/P&gt;&lt;P&gt;        AND R&lt;SUB&gt;XLOEK EQ SPACE AND E&lt;/SUB&gt;KZBEW ='F' AND D&lt;SUB&gt;SPRAS = 'E' AND R&lt;/SUB&gt;KZEAR = 'X' AND C~MATNR IN S_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Divide your inner join  in two  querys  ,  in order to sagrigate data properly and understand problem  easily  .&lt;/P&gt;&lt;P&gt;   you have used  inner join on seven tables  which may hamper  performance  of query  .&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;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Sep 2010 04:51:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256083#M1528260</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2010-09-04T04:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256084#M1528261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello swatig  ,&lt;/P&gt;&lt;P&gt;You can get a  complex query generated by system itself and also check weather the query is fetching the data properly ,&lt;/P&gt;&lt;P&gt;carry on the following steps,&lt;/P&gt;&lt;P&gt;1. Go to sqvi Transaction &lt;/P&gt;&lt;P&gt;2. give a for the QUICK VIEW set and say create  &lt;/P&gt;&lt;P&gt;3. Give title&lt;/P&gt;&lt;P&gt;4. Select data source as Table Join&lt;/P&gt;&lt;P&gt;5. Now you will come to a screen where you can add to TABLES  ( hear you can actually connect..the table fields for join condition )&lt;/P&gt;&lt;P&gt;6. ( once you are done with the above process  press back )&lt;/P&gt;&lt;P&gt;7. select the table fields you want for the list and the selection screen fields ( selection screen field will be those you want in your where condition of you join query )&lt;/P&gt;&lt;P&gt;8. Run the quick view give the proper selection screen fields see if  you are getting your desired results if yes come to the selection screen check the program...this program will have invoked certain system generated Function module in that function module you will get your query..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its easy.... just try it once...!&lt;/P&gt;&lt;P&gt;Search more on same.... on Wiki or sdn&lt;/P&gt;&lt;P&gt;check for the below link you will y get your desired query...!&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.docstoc.com/docs/2585187/SAP-QUERY--SQ01-STEP-BY-STEP-GUIDE" target="test_blank"&gt;http://www.docstoc.com/docs/2585187/SAP-QUERY--SQ01-STEP-BY-STEP-GUIDE&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope it Helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Anup Deshmukh on Sep 4, 2010 7:10 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Sep 2010 05:09:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256084#M1528261</guid>
      <dc:creator>anup_deshmukh4</dc:creator>
      <dc:date>2010-09-04T05:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256085#M1528262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swati,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Try using Distinct option with joins condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT DISTINCT A~FTRMI
              A~AUFNR
              B~MATNR
              D~MAKTX
              B~PSMNG
              B~WEMNG
              C~MTART
              E~CHARG
              C~MATKL
              C~SPART
              R~BWART
              R~CHARG
              R~MATNR
              E~BWART
              R~BDMNG
        INTO TABLE ITAB
        FROM AFKO AS A INNER JOIN AFPO AS B ON A~AUFNR = B~AUFNR
.......
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Swarna Munukoti.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Sep 2010 06:54:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256085#M1528262</guid>
      <dc:creator>former_member217544</dc:creator>
      <dc:date>2010-09-04T06:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256086#M1528263</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;PRE&gt;&lt;CODE&gt;SELECT 
  AFKO~FTRMI
  AFKO~AUFNR            
  AFPO~MATNR            
  MAKT~MAKTX            
  AFPO~PSMNG            
  AFPO~WEMNG            
  MARA~MTART            
  MSEG~CHARG            
  MARA~MATKL            
  MARA~SPART            
  RESB~BWART            
  RESB~CHARG            
  RESB~MATNR            
  MSEG~BWART            
  RESB~BDMNG            
  INTO CORRESPONDING FIELDS OF TABLE ITAB "always use CORRESPONDING FIELDS!!!
  FROM AFKO
  INNER JOIN AFPO ON AFKO~AUFNR = AFPO~AUFNR
  INNER JOIN MARA ON AFPO~MATNR = MARA~MATNR
  INNER JOIN MAKT ON MARA~MATNR = MAKT~MATNR
  INNER JOIN MSEG ON AFPO~MATNR = MSEG~MATNR AND 
                     AFKO~AUFNR = MSEG~AUFNR AND 
                     AFPO~DWERK = MSEG~WERKS
  INNER JOIN RESB ON AFKO~AUFNR = RESB~AUFNR AND 
                     MSEG~AUFNR = RESB~AUFNR AND 
                     RESB~RSNUM = AFKO~RSNUM AND 
                     RESB~WERKS = MSEG~WERKS AND 
                     RESB~BAUGR = MSEG~MATNR
  INNER JOIN MARA AS C1 ON RESB~MATNR = C1~MATNR
  WHERE AFKO~FTRMI IN S_DATE 
    AND AFKO~AUFNR IN S_AUFNR 
    AND MARA~MTART IN S_TYPE 
    AND MARA~MATKL = 'T'
    AND RESB~BWART = '261' 
    AND MSEG~BWART = '101'
    AND RESB~XWAOK = 'X' 
    AND AFPO~DWERK = '2000'
    AND RESB~XLOEK EQ SPACE 
    AND MSEG~KZBEW = 'F' 
    AND MAKT~SPRAS = 'E' 
    AND RESB~KZEAR = 'X' 
    AND MARA~MATNR IN S_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You need no AS alias except you join the same table twice, it helps only non-readability.&lt;/P&gt;&lt;P&gt;I think field AUFPS is missing in the join of MSEG and RESB, this may help. You should add MATNR as well because then the index RESB~M will be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Clemens Li on Sep 4, 2010 10:20 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Sep 2010 20:18:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256086#M1528263</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-09-04T20:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256087#M1528264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i don't think this will be the right way to get your date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use for all entries to all of them then&lt;/P&gt;&lt;P&gt;loop&lt;/P&gt;&lt;P&gt;read&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will also have better debugging to know data from each table youre getting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Sep 2010 03:24:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256087#M1528264</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-05T03:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Inner Join</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256088#M1528265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi every body,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             Thanks for the help. will try each one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Swati&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Sep 2010 03:34:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-inner-join/m-p/7256088#M1528265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-05T03:34:06Z</dc:date>
    </item>
  </channel>
</rss>

