<?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: Select Data from 2 intern tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389071#M1043756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at table1.&lt;/P&gt;&lt;P&gt;move-corresponding table1 to resulttable.&lt;/P&gt;&lt;P&gt;read table table2 with key user = table1-user.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;move-corresponding table2 to resulttable.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append resulttable.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Aug 2008 08:55:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-08-26T08:55:42Z</dc:date>
    <item>
      <title>Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389065#M1043750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how I can select Data from 2 intern Tables into another intern table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Result  Table has the fields: mandt, user, ID, ID_Name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My select table no. 1 has the fields mandt, XYZ (like A_Name), ID, ID_Name, ...&lt;/P&gt;&lt;P&gt;My select table no. 2 has the fields mandt, A_Name, User, ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to search for all entries in select table no. 1 and 2. where are a_name have the same worth.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How I can select my Dates?&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;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:47:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389065#M1043750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389066#M1043751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use join on 2 tables...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check SAP Help for writing join...or search in the forum you will find the code snippet for the same....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kunjal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389066#M1043751</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389067#M1043752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hii&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can do it by using for all entries and with READ statement ..do like follow code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF i_marc[] IS NOT INITIAL.

    SELECT matnr                       " Material Number
           werks                       " Plants
           lgort                       " Storage Location
      FROM mard
      INTO TABLE i_mard
       FOR ALL ENTRIES IN i_marc
     WHERE matnr EQ i_marc-matnr
       AND werks EQ i_marc-werks
       AND lgort IN s_lgort.

  ENDIF.                               " IF i_mara[] IS NOT INITIAL


  IF sy-subrc EQ 0.
    LOOP AT i_output INTO wa_output.
      READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
      wa_output-lgort = wa_mard-lgort.
      MODIFY i_output FROM wa_output.
      CLEAR wa_output.
    ENDLOOP.                           " LOOP AT i_output
  ENDIF.                               " IF sy-subrc EQ 0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;twinkal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:52:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389067#M1043752</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389068#M1043753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, assuming that you do actually mean internal tables rather than transparent tables as other responders seem to think:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming table 2 is smaller than table 1, and that A_Name is unique in table 2 (if not, use a SORTED table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tab3 is your destination table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First make sure you use a TYPES declaration to define the type of table 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then declare table 2 as&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: tab2 TYPE HASHED TABLE OF tab2_type WITH UNIQUE KEY a_name.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Process the data like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT tab1 ASSIGNING &amp;lt;ls_wa1&amp;gt;.
  MOVE-CORRESPONDING &amp;lt;ls_wa1&amp;gt; INTO ls_wa3.
  READ TABLE tab2 WITH TABLE KEY a_name = &amp;lt;ls_wa1&amp;gt;-a_name ASSIGNING &amp;lt;ls_wa2&amp;gt;.
  IF sy-subrc IS INITIAL.
    MOVE-CORRESPONDING &amp;lt;ls_wa2&amp;gt; INTO ls_wa3.
  ENDIF.
  INSERT ls_wa3 INTO TABLE tab3.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:54:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389068#M1043753</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-08-26T08:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389069#M1043754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:54:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389069#M1043754</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389070#M1043755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single &amp;lt;field_name&amp;gt; &lt;/P&gt;&lt;P&gt;from itab1 as t1 &lt;/P&gt;&lt;P&gt;inner join on itab2 as t2 &lt;/P&gt;&lt;P&gt;into corresponding fields of itab3 &lt;/P&gt;&lt;P&gt;where t1&lt;SUB&gt;field1 eq t2&lt;/SUB&gt;field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: field1 is a primary key field in both tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:55:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389070#M1043755</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389071#M1043756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at table1.&lt;/P&gt;&lt;P&gt;move-corresponding table1 to resulttable.&lt;/P&gt;&lt;P&gt;read table table2 with key user = table1-user.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;move-corresponding table2 to resulttable.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append resulttable.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 08:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389071#M1043756</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T08:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389072#M1043757</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;Use join for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select b~user&lt;/P&gt;&lt;P&gt;          a~id&lt;/P&gt;&lt;P&gt;          a~id_name&lt;/P&gt;&lt;P&gt;from table1 as a INNER JOIN table2 as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;A_Name = b&lt;/SUB&gt;A_Name&lt;/P&gt;&lt;P&gt;into corresponding fields of table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will solve your purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Natasha Garg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 09:01:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389072#M1043757</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T09:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389073#M1043758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have many key fields who I does not have and need in my other intern tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How I can avoid that this key fields are requested to provide?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 09:22:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389073#M1043758</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T09:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389074#M1043759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to make a "Join", you can only tka ethe fields you need !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, if you don't need all fields, you can, at the end moving all your data into another itab ( containing only required fields )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at itab.
move-corresponding itab to itab_final.
append itab_final.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erwan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 09:26:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389074#M1043759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T09:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389075#M1043760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Mike clearly wrotes "internal tables" so what should he do with all the select / join statements? The only right way is from Matthew Billing. There is no other way to get the corresponding data as to use READ statement or the LOOP ... WHERE statement, but the second solution is much slower than a READ. if possible use a sorted table and BINARY SEARCH with FIELD-SYMBOLS for performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab1 ASSIGNING &amp;lt;ta1&amp;gt; {WHERE ...}.
  READ itab2 ASSIGNING &amp;lt;ta2&amp;gt; WITH KEY a_name = &amp;lt;ta1&amp;gt;-a_name BINARY SEARCH.
  IF  sy-subrc EQ 0.
       lw_tab3-mandt = &amp;lt;ta1&amp;gt;-mandt.
       lw_tab3-xyz     = &amp;lt;ta1&amp;gt;-xyz.
       lw_tab3-id        = &amp;lt;ta2&amp;gt;-id.
       ...
       APPEND lw_tab3 TO itab3.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 09:30:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389075#M1043760</guid>
      <dc:creator>ingo_barschow</dc:creator>
      <dc:date>2008-08-26T09:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389076#M1043761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 09:43:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389076#M1043761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-08-26T09:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389077#M1043762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;, but the second solution is much slower than a READ. ..&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're referring to my solution, have a second look at it.  It's using a HASHED table which is &lt;STRONG&gt;faster&lt;/STRONG&gt; than a sorted table and using binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2008 14:47:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389077#M1043762</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-08-26T14:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Select Data from 2 intern tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389078#M1043763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;I've wrote not clearly. I don't know how the thread-starter wants to read the table and if its necessary to sort the table various for several work-steps. If I have a lot of records and always want the table sorted by the same key, you're right: hashed table is to be preferred. But if I want the table sorted in various ways, I would prefer a standard table and sort it with sort-statement before reading with binary search. The statement + ... but the second solution is much slower than a READ ...+ means a loop is much slower than a (direct) read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2008 07:42:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-data-from-2-intern-tables/m-p/4389078#M1043763</guid>
      <dc:creator>ingo_barschow</dc:creator>
      <dc:date>2008-08-27T07:42:21Z</dc:date>
    </item>
  </channel>
</rss>

