<?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: Join on Internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449668#M828681</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use for all entries&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2008 11:20:41 GMT</pubDate>
    <dc:creator>SantoshKallem</dc:creator>
    <dc:date>2008-02-26T11:20:41Z</dc:date>
    <item>
      <title>Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449667#M828680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ppl,&lt;/P&gt;&lt;P&gt;I have 2 internal tables.&lt;/P&gt;&lt;P&gt;I want to write a select query to select 2 fields from one internal table and 1 field from another internal table.&lt;/P&gt;&lt;P&gt;These 3 fields will be selected in a third internal table.&lt;/P&gt;&lt;P&gt;Fields to be selected: gt_mast-matnr&lt;/P&gt;&lt;P&gt;                                gt_mast-werks&lt;/P&gt;&lt;P&gt;                                gt_afko-aufld&lt;/P&gt;&lt;P&gt;Into internal table gt_csbe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to achieve this?&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;David.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 11:01:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449667#M828680</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T11:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449668#M828681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use for all entries&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 11:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449668#M828681</guid>
      <dc:creator>SantoshKallem</dc:creator>
      <dc:date>2008-02-26T11:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449669#M828682</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;It can achieved by using Inner Join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the sample code for using Inner Join:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inner joins using 3 tables  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this :- &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge  
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast  
JOIN stpo ON stpo~stlnr = mast~stlnr  
JOIN mara ON mara~matnr = mast~matnr  
WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr  
AND mast~werks = 1000.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here s_matnr is a select-options on the selection-screen.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or this.  &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;This code locates sales, delivery and payment terms info from a billing document number.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, this one also works fine : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura  
zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1  
zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint  
into it_lista  
from zfpcd inner join zcdvs  
on zfpcd~ebeln = zcdvs~ebeln  
and zfpcd~proforma = zcdvs~proforma  
and zfpcd~lifnr = zcdvs~lifnr  
inner join lfa1  
on zfpcd~lifnr = lfa1~lifnr  
where zcdvs~status = '04'.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Chandra Sekhar.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:43 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 11:25:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449669#M828682</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T11:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449670#M828683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing I would like to tell you that you can not use SELECT clause on the internal table, you can use on the databasae table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we will come to your requirement. I guess you are having 2 internal table named gt_mast &amp;amp; gt_afko and you want to add matnr and werks from gt_mast and aufld from gt_afko into new internal table gt_csbe, for that you have to loop any one internal table say gt_mast and read other internal table say gt_afko into the loop using any of the key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only you have to make sure that in both the internal table there should be common key field or unique record so that you can get the proper data into third internal table gt_csbe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you provide me the structure of all 3 internal tables with the exact requirement so that I shall help you to get the things done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Prashant Raichurkar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:44 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 11:55:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449670#M828683</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T11:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449671#M828684</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;try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
appending lines of i_tab1 to i_tab2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if fields are not same&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at i_tab1
  v_tabix = sy-tabix.
  read table i_tab3 with key &amp;lt;key fields of i_tab1&amp;gt;
  if sy-subrc eq 0.
    move corresponding fields i_tab1 to i_tab3.
    modify i_tab3 index v_tabix..
  else.
    move corresponding fields i_tab1 to i_tab3.
    append i_tab3.    
 endif.
endloop.
 
loop at i_tab2
  v_tabix = sy-tabix.
  read table i_tab3 with key &amp;lt;key fields of i_tab2&amp;gt;
  if sy-subrc eq 0.
    move corresponding fields i_tab2 to i_tab3.
    modify i_tab3 index v_tabix..
  else.
    move corresponding fields i_tab2 to i_tab3.
    append i_tab3.    
 endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:44 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 12:02:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449671#M828684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T12:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Join on Internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449672#M828685</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;Select field1 field2 from SomeTable into corresponding field of table IT1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select field1 from SomeTable into corresponding field of table IT2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at IT1 into WA1 with key WA1-matnr.&lt;/P&gt;&lt;P&gt;   read table IT2 into WA2 with key WA2-matnr = &amp;lt;some  common field&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       WA_gt_csbe-matnr = WA1_gt_mast-matnr&lt;/P&gt;&lt;P&gt;       WA_gt_csbe-werks = WA1_gt_mast-werks&lt;/P&gt;&lt;P&gt;      WA_gt_csbe-aufld = WA2-aufld&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append WA_gt_csbe to IT_gt_csbe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dhruv Shah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 12:03:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-internal-tables/m-p/3449672#M828685</guid>
      <dc:creator>dhruv_shah3</dc:creator>
      <dc:date>2008-02-26T12:03:02Z</dc:date>
    </item>
  </channel>
</rss>

