<?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: internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787401#M649970</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eliana,&lt;/P&gt;&lt;P&gt;By your example your results may vary or be inaccurate. Main internal table should be your main loop, and temp is your lookup table. Your temp table should be sorted by fielda and fieldb and use binary search. Main will have a header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at main.&lt;/P&gt;&lt;P&gt;..read temp with key fielda = main-fielda and fieldb = main-fieldb binary search.&lt;/P&gt;&lt;P&gt;..if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;....main-fieldc = temp-fieldc.&lt;/P&gt;&lt;P&gt;....modify main.&lt;/P&gt;&lt;P&gt;..endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, you will have a problem, because in your temp table, you have the same key (fielda, fieldb) 3 times, 123 10. So which value would you want? So I assume this was just an example error. Your temp table should look more like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;123 10 999&lt;/P&gt;&lt;P&gt;123 11 998&lt;/P&gt;&lt;P&gt;123 12 996&lt;/P&gt;&lt;P&gt;124 10 999&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Point: you should always use a sorted table and read with binary search, only time you might not is if you have less than 10 records. But generally, use Binary search and don't forget to sort the table or define the table as type sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Filler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Sep 2007 03:30:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-12T03:30:35Z</dc:date>
    <item>
      <title>internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787398#M649967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;may i know how to move fieldc in temp internal table to main internal table fieldc and overrite the fieldc in main internal table when fielda and fieldb are the same?&lt;/P&gt;&lt;P&gt;notice that sometimes temp table entry may less. for example fielda 124 is only 1 entry in temp but want to update the corresponding entry in main internal table which has 2 entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main internal table&lt;/P&gt;&lt;P&gt;fielda fieldb fieldc &lt;/P&gt;&lt;P&gt;123   10     999&lt;/P&gt;&lt;P&gt;123   10     999&lt;/P&gt;&lt;P&gt;123   10     999&lt;/P&gt;&lt;P&gt;124   10     sss&lt;/P&gt;&lt;P&gt;124   10     sss&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp internal table&lt;/P&gt;&lt;P&gt;fielda fieldb fieldc &lt;/P&gt;&lt;P&gt;123   10     999&lt;/P&gt;&lt;P&gt;123   10     998&lt;/P&gt;&lt;P&gt;123   10     997&lt;/P&gt;&lt;P&gt;124   10     see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 02:45:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787398#M649967</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T02:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787399#M649968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    I dont find any necessity of using temporary internal table over here. You can directly compare field content of&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; fielda&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; and&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; fieldb&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; and by using &amp;lt;b&amp;gt;modify&amp;lt;/b&amp;gt; keyword, we can update the main internal table. So that you can get what expecting. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;begin of itab&lt;/P&gt;&lt;P&gt;fielda&lt;/P&gt;&lt;P&gt;fieldb&lt;/P&gt;&lt;P&gt;fieldc&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : wa like itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa.&lt;/P&gt;&lt;P&gt;if wa-fielda = wa-fieldb.&lt;/P&gt;&lt;P&gt; fieldc = 'see'.  &lt;/P&gt;&lt;P&gt;modify itab form wa transporting fieldc.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dont forget to Reward points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreenivasa sarma k.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 02:57:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787399#M649968</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T02:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787400#M649969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at temp.&lt;/P&gt;&lt;P&gt;  if temp-fielda = temp-fieldb.&lt;/P&gt;&lt;P&gt;    read table main index sy-tabix.&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;       move temp-fieldc to main-fieldc.&lt;/P&gt;&lt;P&gt;       modify main.&lt;/P&gt;&lt;P&gt;       clear main.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mithun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 02:59:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787400#M649969</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T02:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787401#M649970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eliana,&lt;/P&gt;&lt;P&gt;By your example your results may vary or be inaccurate. Main internal table should be your main loop, and temp is your lookup table. Your temp table should be sorted by fielda and fieldb and use binary search. Main will have a header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at main.&lt;/P&gt;&lt;P&gt;..read temp with key fielda = main-fielda and fieldb = main-fieldb binary search.&lt;/P&gt;&lt;P&gt;..if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;....main-fieldc = temp-fieldc.&lt;/P&gt;&lt;P&gt;....modify main.&lt;/P&gt;&lt;P&gt;..endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, you will have a problem, because in your temp table, you have the same key (fielda, fieldb) 3 times, 123 10. So which value would you want? So I assume this was just an example error. Your temp table should look more like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;123 10 999&lt;/P&gt;&lt;P&gt;123 11 998&lt;/P&gt;&lt;P&gt;123 12 996&lt;/P&gt;&lt;P&gt;124 10 999&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Point: you should always use a sorted table and read with binary search, only time you might not is if you have less than 10 records. But generally, use Binary search and don't forget to sort the table or define the table as type sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Filler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 03:30:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787401#M649970</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T03:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787402#M649971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;loop at it_main into is_main.
read table it_temp into is_temp with key fielda = is_main-fielda
                                         fieldb = is_main-fieldb.
if sy-subrc = 0.
  move is_temp-fieldc to is_main-fieldc.
  modify it_main from is_main transporting fieldc.
endif.
clear : is_main, is_temp.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you do this way your ouptu will be this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fielda fieldb fieldc &lt;/P&gt;&lt;P&gt;123 10 999&lt;/P&gt;&lt;P&gt;123 10 999&lt;/P&gt;&lt;P&gt;123 10 999&lt;/P&gt;&lt;P&gt;124 10 see&lt;/P&gt;&lt;P&gt;124 10 see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i doubt this is not what you need because in main table you will have duplicate entries.&lt;/P&gt;&lt;P&gt;so make clear ur requirement..before u proceed with my code.&lt;/P&gt;&lt;P&gt;and use / change the code accordingly to meet your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 03:34:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787402#M649971</guid>
      <dc:creator>gopi_narendra</dc:creator>
      <dc:date>2007-09-12T03:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787403#M649972</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;my fielda and fieldb would be repeated. that is the problem i need to ask for help.&lt;/P&gt;&lt;P&gt;temp table entry may less as per my first post.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 03:56:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787403#M649972</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T03:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787404#M649973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use this is the record in ur table is repeated&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM itab.&lt;/P&gt;&lt;P&gt;then with simple read and modify u can tranfer the records from one table to another&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 04:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table/m-p/2787404#M649973</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T04:50:17Z</dc:date>
    </item>
  </channel>
</rss>

