<?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: combine two internal table using function module table output in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355215#M7196</link>
    <description>&lt;P&gt;Yes, avoid this latest code. Use the earliest code (LOOP + READ TABLE).&lt;/P&gt;&lt;P&gt;If your only issue is with the 2 "overlapping" MOVE-CORRESPONDING, then just indicate the fields one by one.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2016 16:32:16 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2016-12-28T16:32:16Z</dc:date>
    <item>
      <title>combine two internal table using function module table output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355212#M7193</link>
      <description>&lt;P&gt;Hi there &lt;/P&gt;&lt;P&gt;Let me apologize in advance if I'm breaking any guidelines. I'm quite new to this.  I'm usually the type that ones to figure things out myself but I've invested to mush time in this problem. I've looked trough the archive but couldn't find anything that meets my criteria.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is my situation :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. I've one&lt;STRONG&gt; function module&lt;/STRONG&gt; that does a select on my&lt;STRONG&gt; Z_table&lt;/STRONG&gt; and  returns an internal table with the fallowing fields (the fields are based on abap table "vttk" ) :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;shipment_number (tknum in vttk)&lt;/LI&gt;&lt;LI&gt;planning_date  (dpreg in vttk)&lt;/LI&gt;&lt;LI&gt;time_in (uareg in vttk) &lt;/LI&gt;&lt;LI&gt;time_out (uatend in vttk)&lt;/LI&gt;&lt;LI&gt;remarks (custom field)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Lets call this internal table returned by our function module &lt;STRONG&gt;it_shipm_data&lt;/STRONG&gt;. The data elements are the same as that of vttk.&lt;/P&gt;&lt;P&gt;2. I've an custom internal table structure with the fallowing fields (again based on vttk)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;tknum&lt;/LI&gt;&lt;LI&gt;dpreg&lt;/LI&gt;&lt;LI&gt;uareg&lt;/LI&gt;&lt;LI&gt;uaten&lt;/LI&gt;&lt;LI&gt;tplst &lt;/LI&gt;&lt;LI&gt;erdat&lt;/LI&gt;&lt;LI&gt;fabkl (field from another table made possible by doing a join).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Lets call this internal table structure &lt;STRONG&gt;ls_shipm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;3. I've also made an internal table structure that contains all the above fields. I got this tip from you guys.&lt;/P&gt;&lt;P&gt;Lets call this in internal table structure &lt;STRONG&gt;ls_final_shipm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is my problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As you may have noticed internal table &lt;STRONG&gt; it_shipm&lt;/STRONG&gt; more fields then internal table &lt;STRONG&gt;it_shipm_data&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;WHAT I WANT&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I need to get all these data together in one table:&lt;/P&gt;&lt;P&gt;The field value in &lt;STRONG&gt;it_shipm_data&lt;/STRONG&gt; &lt;STRONG&gt;&lt;U&gt;MOST&lt;/U&gt;&lt;/STRONG&gt; overwrite the corresponding field values in &lt;STRONG&gt;it_shipm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;if I was working with a regular abap/Z-table a simple join would have done the job.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Some codes:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: it_shipm TYPE TABLE OF ls_shipm,  "custom internal table
      wa_shipm TYPE ls_shipm,
      it_shipm_data TYPE TABLE OF z_table, "returned internal table from FM
      wa_shipm_data TYPE z_table,
      it_final TYPE TABLE OF ls_final_shipm,
      wa_final TYPE ls_final_shipm.      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;What I've tried so far that came close to what I was looking for thanks to you guys&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_shipm_data INTO wa_shipm_data 
  READ TABLE it_shipm INTO wa_shipm 
                           WITH KEY tknum = wa_shipm_data-shipment_number 
  IF sy-subrc =0.
     MOVE-CORRESPONDING wa_shipm TO wa_final.
     MOVE_CORRESPONDING wa_shipm_data to wa_final.
     APPEND wa_final to it_final.
     CLEAR  wa_final.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Result problems:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When i loop over it_final to see what it has stored i noticed the fallowing&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Only the tknum (shipment number are the same) &lt;/LI&gt;&lt;LI&gt;All the other values are from &lt;STRONG&gt;it_shipm&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So basicly &lt;STRONG&gt;no value of it_shipm_data &lt;/STRONG&gt;(my Z-table values) are being passed.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Am I asking the impossible ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I know this is a long post.&lt;/P&gt;&lt;P&gt;I just want to provide a mush information as possible to make it easier to debug.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 18:01:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355212#M7193</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-25T18:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: combine two internal table using function module table output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355213#M7194</link>
      <description>&lt;P&gt;My guess would be the names of the z_table fields and the internal table don't match up exactly and the data is not being passed in the second move-corresponding wa_shipm_data to wa_final.  Have you tried mapping the fields manually to see if that's the problem?  (i.e. wa_final-dpreg = wa_shipm_data-dpreg?&lt;/P&gt;&lt;P&gt; If that works then you could use the CORRESPONDING component operator to get what you're looking for and replace the move-corresponding.  &lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/abapdocu_740/en/index.htm?file=abapmove-corresponding.htm" target="test_blank"&gt;http://help.sap.com/abapdocu_740/en/index.htm?file=abapmove-corresponding.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 16:22:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355213#M7194</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-27T16:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: combine two internal table using function module table output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355214#M7195</link>
      <description>&lt;P&gt;Hey there thanks for your input.&lt;/P&gt;&lt;P&gt;To answer your question, yes you're right data wasn't being passed correctly so i had to &lt;STRONG&gt;remove everything and start over&lt;/STRONG&gt;.&lt;BR /&gt;this time making sure that I checked every step. Eventually noticed that I was looking at it &lt;STRONG&gt;the wrong way &lt;/STRONG&gt;after browsing trough this site. I saw something unrelated to my problem and decided to try it after a (long) while it hit me.&lt;/P&gt;&lt;P&gt;After re-evaluating this is the solution i came up with to fix my problem for combining the two tables. &lt;STRONG&gt;Again my apologize for any confusion I may have caused.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;I not to sure if my solution is performance friendly because I've read somewhere on this site that you should try to avoid using a select in a loop. So if anyone knows how I can make this more performance friendly I'm all ears (please no OOP my knowledge isn't on point for that).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_shipm_data into wa_ship_data  "this is the internal table returned by my function module 
  wa_final-field1  =  wa_ship_data       "pushing all the field from my final internal table
    .....
  SELECT * FROM vttk INTO CORRESPONDING FIELDS OF wa_final   "getting the remaining fields that i need &lt;BR /&gt;             WHERE tknum = wa_ship_data-tknum.     
      ENDSELECT.
APPEND wa_final TO it final.&lt;BR /&gt;ENDLOOP&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Dec 2016 01:55:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355214#M7195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-28T01:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: combine two internal table using function module table output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355215#M7196</link>
      <description>&lt;P&gt;Yes, avoid this latest code. Use the earliest code (LOOP + READ TABLE).&lt;/P&gt;&lt;P&gt;If your only issue is with the 2 "overlapping" MOVE-CORRESPONDING, then just indicate the fields one by one.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 16:32:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/combine-two-internal-table-using-function-module-table-output/m-p/355215#M7196</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-12-28T16:32:16Z</dc:date>
    </item>
  </channel>
</rss>

