<?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: INNER JOIN in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554406#M582040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You join the tables VBAK VBAP with VBELN field and VBAP-MATNR field with MAKT-MATNR field and fetch the data&lt;/P&gt;&lt;P&gt;sample select&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr  c~maktx into table itab&lt;/P&gt;&lt;P&gt;from vbak as a join vbap as b on a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln &lt;/P&gt;&lt;P&gt;join makt as c on b&lt;SUB&gt;matnr = c&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;where a~kunnr in s_kunnr and&lt;/P&gt;&lt;P&gt;          a~audat in s_audat and&lt;/P&gt;&lt;P&gt;          a~auart in s_auart and&lt;/P&gt;&lt;P&gt;          c~spras = sy-langu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points for useful Answers&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jul 2007 06:43:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-16T06:43:12Z</dc:date>
    <item>
      <title>INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554404#M582038</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 want  o write the program like this. Plz suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Selection screen should be customer numbr, sales document date and sales document type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want kunnr, name, sales doc date, doc category, item, matnr, qty, netpr, value and join MAKT table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plz suggest me how to go about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 06:36:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554404#M582038</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T06:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554405#M582039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rams&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;The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Check this sample code&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of wa_mkpfmseg,
      mblnr like mkpf-mblnr,
      mjahr like mkpf-mjahr,
      zeile like mseg-zeile,
      bukrs like mseg-bukrs
        bwart like mseg-bwart,
        budat like mkpf-budat,
      cputm like mkpf-cputm,
        matnr like mseg-matnr,
     werks like mseg-werks,
        ebeln like mseg-ebeln,
        ebelp like mseg-ebelp,
        erfmg like mseg-erfmg,
        end of wa_mkpfmseg.

data ht_mkpfmseg like hashed table of wa_mkpfmseg
         with unique key mblnr mjahr zeile
       with header line.

data: begin of wa_mkpfmsegSel,
        budat like mkpf-budat,
      cputm like mkpf-cputm,
        matnr like mseg-matnr,
      werks like mseg-werks,
        ebeln like mseg-ebeln,
        ebelp like mseg-ebelp,
        erfmg like mseg-erfmg,
        end of wa_mkpfmseg.


data ht_mkpfmsegSel like hashed table of wa_mkpfmsegSel
         with unique key budat cputm matnr werks ebeln ebelp 
       with header line.

** change your select sentence to look like this:
  select mkpf~mblnr
              mkpf~mjahr
              mseg~zeile
            mseg~bukrs 
           mseg~bwart
        MKPF~BUDAT MKPF~CPUTM
             MSEG~MATNR MSEG~WERKS MSEG~EBELN 
             MSEG~EBELP  MSEG~ERFMG
                  INTO  TABLE ht_mkpfmseg
                  FROM MKPF INNER JOIN MSEG
                       ON   mkpf~mandt = mseg~mandt 
                  AND    MKPF~MBLNR = MSEG~MBLNR
                  AND MKPF~MJAHR = MSEG~MJAHR
                 where mkpf~budat &amp;gt; '20040721'.

  loop at ht_mkpfmseg.
                check ht_mkpfmseg-bukrs = '1733' and ht_mkpfmseg-bwart = '101'          
                read table ht_mkpfmsegsel with table key   
                     budat = ht_mkpfmseg-budat
                     cputm = ht_mkpfmseg-cputm                                                                                
matnr  = ht_mkpfmseg-matnr          
                     werks  = ht_mkpfmseg-werks                                                   

                     ebeln = ht_mkpfmseg-ebeln   
                     ebelp  = ht_mkpfmseg-ebelp
                transporting erfmg.
                if sy-subrc &amp;lt;&amp;gt; 0.
                   move-corresponding ht_mkpfmseg to ht_mkpfmsegsel.
                   insert table ht_mkpfmsegsel.
                else.
                        ht_mkpfmsegSel-budat = ht_mkpfmseg-budat.
                        ht_mkpfmsegSel-cputm = ht_mkpfmseg-cputm.
                        ht_mkpfmsegSel-matnr = ht_mkpfmseg-matnr,
                        ht_mkpfmsegSel-werks = ht_mkpfmseg-werks.
                        ht_mkpfmsegSel-ebeln = ht_mkpfmseg-ebeln.
                        ht_mkpfmsegSel-ebelp = ht_mkpfmseg-ebelp.
                        add ht_mkpfmseg-erfmg to ht_mkpfmsegSel-erfmg.
                        modify table ht_mkpfmsegSel transporting erfmg.
                endif.
  endloop.
  " at this point ht_mkpfmsegSel has the data collected that you want. 
  loop at ht_mkpfmsegSel.
        .... Here put the code between your select ... endselect.
   endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;&amp;lt;b&amp;gt;Check this for joining 3 tables&amp;lt;/b&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; Select single Vbrk~Bukrs Vbrk~Kunrg    Vbrk~Vbeln  
                   Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm  
                   Tvzbt~Vtext  
                   Vbak~Vbeln Vbak~Bstdk  
                   Likp~Vbeln Likp~lfdat    Likp~Lfuhr  
       into w_vbrk  
       from vbrk  
      inner join       Tvzbt on Tvzbt~Zterm        = Vbrk~Zterm      and  
                                Tvzbt~Spras        = sy-langu  
      Inner join       Vbfa  as SalesLnk  
                             on SalesLnk~vbeln     = pu_vbeln        and  
                                SalesLnk~vbtyp_v   = c_order  
            inner join Vbak  on Vbak~Vbeln           = SalesLnk~Vbelv 
      Inner join       Vbfa  as DeliveryLnk  
                             on DeliveryLnk~vbeln   = pu_vbeln       and  
                                DeliveryLnk~vbtyp_v = c_Delivery  
            inner join Likp  on Likp~Vbeln          = DeliveryLnk~Vbelv  
      where vbrk~vbeln = pu_Vbeln.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;This code locates sales, delivery and payment terms info from a billing document number.&amp;lt;/b&amp;gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward all helpfull answers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 06:40:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554405#M582039</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T06:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: INNER JOIN</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554406#M582040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You join the tables VBAK VBAP with VBELN field and VBAP-MATNR field with MAKT-MATNR field and fetch the data&lt;/P&gt;&lt;P&gt;sample select&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr  c~maktx into table itab&lt;/P&gt;&lt;P&gt;from vbak as a join vbap as b on a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln &lt;/P&gt;&lt;P&gt;join makt as c on b&lt;SUB&gt;matnr = c&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;where a~kunnr in s_kunnr and&lt;/P&gt;&lt;P&gt;          a~audat in s_audat and&lt;/P&gt;&lt;P&gt;          a~auart in s_auart and&lt;/P&gt;&lt;P&gt;          c~spras = sy-langu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points for useful Answers&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2007 06:43:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inner-join/m-p/2554406#M582040</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-16T06:43:12Z</dc:date>
    </item>
  </channel>
</rss>

