<?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: Joining 3 Tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083234#M976322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Supriya,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;1) First query the stpo table based on matnr which is referred as idnrk and store in to an internal table i_stpo.&lt;/P&gt;&lt;P&gt;2) Take a temporary internal table i_tempstpo and store unique materials from  i_stpo&lt;/P&gt;&lt;P&gt;3) Second query the mara table by using the i_tempstpo table with condition matnr eq i_stpo-idnrk and retrieve the required fields.&lt;/P&gt;&lt;P&gt;4) Third query the mbew table by using the i_tempstpo table with condition matnr eq i_stpo-idnrk and retrieve the required fields..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if there are any issues. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2008 06:34:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-08T06:34:19Z</dc:date>
    <item>
      <title>Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083227#M976315</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;My requirement is to joining 3 table i.e. mara,stpo,mbew .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fields are matnr mtart ,extwg ,verpr, idnrk(domain is stpo-matnr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please give me the code for the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please gimme the logic for the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points will be rewarded .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Supriya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 04:54:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083227#M976315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T04:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083228#M976316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Supriya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Better you take the data from STPO first as per the matnr and then use for all entries to get the data from MARA and MBEW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joining these three tables is not adviceable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgrds,&lt;/P&gt;&lt;P&gt;Rahul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:06:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083228#M976316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083229#M976317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;check below coding..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: mara,stpo,mbew.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;      matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;      mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;      extwg like mara-extwg,&lt;/P&gt;&lt;P&gt;      verpr like mbew-verpr,&lt;/P&gt;&lt;P&gt;      idnrk like stpo-idnrk,&lt;/P&gt;&lt;P&gt;      end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      select a&lt;SUB&gt;matnr a&lt;/SUB&gt;mtart a&lt;SUB&gt;extwg b&lt;/SUB&gt;verpr c~idnrk from mara&lt;/P&gt;&lt;P&gt;      as a left outer join mbew as b on a&lt;SUB&gt;matnr eq b&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;      left outer join stpo as c on a&lt;SUB&gt;matnr eq c&lt;/SUB&gt;idnrk&lt;/P&gt;&lt;P&gt;      into corresponding fields of table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:25:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083229#M976317</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083230#M976318</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 think your requirement is to retieve the BOM Component information,if it is your requirement then use this Function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CS_BOM_EXPL_MAT_V2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You will get all the components related to material then get costs from MBEW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Suman.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:30:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083230#M976318</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083231#M976319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Supriya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;tables :
 mara,
 stpo,
 mbew.
 
data :
  begin of t_mat occurs 0,
    matnr like mara-matnr,
    mtart like mara-mtart,
    extwg like mara-extwg,
    idnrk like stpo-idnrk,
    verpr like mbew-verpr,
  end of t_mat.  
  
 select m~matnr
        m~mtart
        m~extwg
        s~idnrk
        w~verpr
   from mara as m
   join stpo as s 
     on m~matnr = s~idnrk
   join mbew as w
     on m~matnr = w~matnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Swapna.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: NagaSwapna Thota on Jul 8, 2008 7:36 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: NagaSwapna Thota on Jul 8, 2008 7:37 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:36:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083231#M976319</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083232#M976320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hiii!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_sdn.

DATA:
  BEGIN OF fs_mat,
    matnr TYPE mara-matnr,
    mtart TYPE mara-mtart,
    extwg TYPE mara-extwg,
    verpr TYPE mbew-verpr,
    idnrk TYPE stpo-idnrk,
  END OF fs_mat.

DATA:
  t_mat LIKE
  TABLE OF
        fs_mat.


START-OF-SELECTION.
  PERFORM get_data.
  LOOP AT t_mat INTO fs_mat.
    WRITE: / fs_mat-matnr,
             fs_mat-mtart,
             fs_mat-extwg,
             fs_mat-verpr,
             fs_mat-idnrk.
  ENDLOOP.

FORM get_data .
  SELECT a~matnr
         a~mtart
         a~extwg
         b~verpr
         c~idnrk
    FROM mara
      AS a LEFT OUTER JOIN mbew AS
         b ON a~matnr EQ b~matnr
         LEFT OUTER JOIN stpo
      AS c ON a~matnr EQ c~idnrk
    INTO CORRESPONDING FIELDS OF TABLE t_mat.

ENDFORM.                    " get_data

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhijeet Kulshreshtha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:37:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083232#M976320</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083233#M976321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Supriya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: mara,stpo,mbew.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;mtart like mara-mtart,&lt;/P&gt;&lt;P&gt;extwg like mara-extwg,&lt;/P&gt;&lt;P&gt;idnrk like stpo-idnrk,&lt;/P&gt;&lt;P&gt;verpr like mbew-verpr,&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select mara&lt;SUB&gt;matnr mara&lt;/SUB&gt;mtart mara&lt;SUB&gt;extwg mbew&lt;/SUB&gt;matnr stpo~idnrk from mara into corresponding fields of itab &lt;/P&gt;&lt;P&gt;JOIN mbew on mara&lt;SUB&gt;matnr = mbew&lt;/SUB&gt;matnr JOIN&lt;/P&gt;&lt;P&gt;stpo on mara&lt;SUB&gt;matnr = stpo&lt;/SUB&gt;idnrk.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See if it works&lt;/P&gt;&lt;P&gt;But joining three tables reduces performance analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sharmi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 05:48:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083233#M976321</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T05:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 3 Tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083234#M976322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Supriya,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;1) First query the stpo table based on matnr which is referred as idnrk and store in to an internal table i_stpo.&lt;/P&gt;&lt;P&gt;2) Take a temporary internal table i_tempstpo and store unique materials from  i_stpo&lt;/P&gt;&lt;P&gt;3) Second query the mara table by using the i_tempstpo table with condition matnr eq i_stpo-idnrk and retrieve the required fields.&lt;/P&gt;&lt;P&gt;4) Third query the mbew table by using the i_tempstpo table with condition matnr eq i_stpo-idnrk and retrieve the required fields..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if there are any issues. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2008 06:34:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-3-tables/m-p/4083234#M976322</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-08T06:34:19Z</dc:date>
    </item>
  </channel>
</rss>

