<?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 merging two internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732470#M1581117</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;I have a slight problem, I have two internal tables that I wish to merge into one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first i_GFSB contains matnr,werk,verpr,peinh from mbew&lt;/P&gt;&lt;P&gt;The second i_GFSBData has matnr, &amp;lt; i_GFSB-werk&amp;gt;, &amp;lt; i_GFSB-verpr&amp;gt;, &amp;lt; i_GFSB-peinh&amp;gt; ,bwky,verpr,peinh also from mbew&lt;/P&gt;&lt;P&gt;The &amp;lt;&amp;gt; are the fields from i_GFSB that I need to 'insert' into i_GFSBData&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i_GFSB contains data from a single plant (and the records are distinct)&lt;/P&gt;&lt;P&gt;i_GFSBData contains data for multiple plants (again distinct records)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am trying to do is insert the i_GFSB data when the matnr is the same in both tables.&lt;/P&gt;&lt;P&gt;Sounds simple, probably is but this is my first real ABAP program and I am a little confused.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any variable like a python dictionary? If so I could do this in a flash&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Apr 2011 14:41:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-04-06T14:41:13Z</dc:date>
    <item>
      <title>merging two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732470#M1581117</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;I have a slight problem, I have two internal tables that I wish to merge into one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first i_GFSB contains matnr,werk,verpr,peinh from mbew&lt;/P&gt;&lt;P&gt;The second i_GFSBData has matnr, &amp;lt; i_GFSB-werk&amp;gt;, &amp;lt; i_GFSB-verpr&amp;gt;, &amp;lt; i_GFSB-peinh&amp;gt; ,bwky,verpr,peinh also from mbew&lt;/P&gt;&lt;P&gt;The &amp;lt;&amp;gt; are the fields from i_GFSB that I need to 'insert' into i_GFSBData&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i_GFSB contains data from a single plant (and the records are distinct)&lt;/P&gt;&lt;P&gt;i_GFSBData contains data for multiple plants (again distinct records)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am trying to do is insert the i_GFSB data when the matnr is the same in both tables.&lt;/P&gt;&lt;P&gt;Sounds simple, probably is but this is my first real ABAP program and I am a little confused.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any variable like a python dictionary? If so I could do this in a flash&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 14:41:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732470#M1581117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-06T14:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: merging two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732471#M1581118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: wa_gfsb like line of i_gfsb,
      wa_gfsbdata like line of i_gfsbdata,
      lv_tabix type sy-tabix.

* Sort Table by Plant.
sort i_gfsbdata by matnr.

loop at i_gfsb into wa_gfsb.

	read table i_gfsbdata into wa_gfsbdata 
	with key matnr = wa_gfsb-matnr binary search.

	if sy-subrc is initial.
		lv_tabix = sy-tabix.
		
		loop at i_gfsbdata into wa_gfsbdata 
		from lv_tabix.

			if wa_gfsbdata-matnr ne wa_gfsb-matnr.
			   exit.
			else.
				wa_gfsbdata-werks = wa_gfsb-werks.			
				wa_gfsbdata-verpr = wa_gfsb-verpr.
				wa_gfsbdata-peinh = wa_gfsb-peinh.
				modify i_gfsbdata from wa_gfsbdata.
			endif.
			clear wa_gfsbdata.
		endloop.
	endif.
	 
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Ernesto&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ernesto Caballero on Apr 6, 2011 4:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 14:58:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732471#M1581118</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-06T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: merging two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732472#M1581119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ernesto&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah thats the ticket, all working fine now. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Apr 2011 06:49:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-two-internal-tables/m-p/7732472#M1581119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-04-07T06:49:17Z</dc:date>
    </item>
  </channel>
</rss>

