<?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: merging the data from two different internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967057#M68766</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This isn't clean, but I think it should work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: next_rec like sy-tabix,
      indexb   like sy-tabix,
      indexc   like sy-tabix.            

loop at bdata into wa.
  indexb = sy-tabix.
*  do some stuff
  loop at cdata into wac.
  indexc = sy-tabix.
*    do some more stuff
    if wac-kschl = 'ZBET'.
      next_rec = indexb + 1.
      read table bdata index next_rec.
*       do some more stuff
      sy-tabix = indexc.
    endif.
  endloop.
  sy-tabix = indexb.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't compiled this so check it. The main thing to do is to keep track of where you are in the tables, determine the index of the next record, read it, reset the index. (I think I've set and reset more times than necessary.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'm not sure that this is very efficient. Nested loops will read every record in the second table twice for every pass through the first one in the first table. A better approach is to use indexed reads if possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jul 2005 20:50:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-07-11T20:50:39Z</dc:date>
    <item>
      <title>merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967052#M68761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi folks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need your help here. I have to populate the internal table 'accitab'. &lt;/P&gt;&lt;P&gt;The 'accitab' has field structure like this.&lt;/P&gt;&lt;P&gt;zdateproductcode&lt;/P&gt;&lt;P&gt;zadnumber&lt;/P&gt;&lt;P&gt;zdescription&lt;/P&gt;&lt;P&gt;zadsize&lt;/P&gt;&lt;P&gt;zrate&lt;/P&gt;&lt;P&gt;zsubtotal&lt;/P&gt;&lt;P&gt;zamount&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The first four fields of data has been pulled into 'BDATA' ITAB  by a different query while the last three field data has been pulled into CDATA' ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;question 1 is how to merge the data from two different queries and taking into a single record into 'accitab'.&lt;/P&gt;&lt;P&gt;Here The code goes like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select vavtyp jhamot&lt;SUB&gt;breite_s jhamot&lt;/SUB&gt;HOEHE_S         jhaga&lt;SUB&gt;avm_nr jhaga&lt;/SUB&gt;ber_termin from zzjhtfp&lt;/P&gt;&lt;P&gt;    INNER JOIN jhamot ON zzjhtfp&lt;SUB&gt;aubel = jhamot&lt;/SUB&gt;avm_nr&lt;/P&gt;&lt;P&gt;     Inner join jhaga on jhamot&lt;SUB&gt;avm_nr = jhaga&lt;/SUB&gt;avm_nr&lt;/P&gt;&lt;P&gt;      INTO corresponding fields of table BDATA WHERE&lt;/P&gt;&lt;P&gt;                  zzjhtfp~inserent = p_advnum and&lt;/P&gt;&lt;P&gt;                        jhaga~fakdatum in r_datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         select * into corresponding fields of table ijha&lt;/P&gt;&lt;P&gt;        from jhak&lt;/P&gt;&lt;P&gt;           inner join jhaga&lt;/P&gt;&lt;P&gt;             on jhak&lt;SUB&gt;avm_nr = jhaga&lt;/SUB&gt;avm_nr&lt;/P&gt;&lt;P&gt;                  where jhaga~inserent = p_advnum and&lt;/P&gt;&lt;P&gt;                  jhaga~fakdatum in r_datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    select  kposn kschl krech kawrt kbetr kwert&lt;/P&gt;&lt;P&gt;        from konv into table cdata for all entries in ijha&lt;/P&gt;&lt;P&gt;                where konv~knumv = ijha-knumv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;fetching the data for the first three fields. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       LOOP AT BDATA into wa. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           write:wa-ber_termin to zdate ddmmyy.&lt;/P&gt;&lt;P&gt;           write: zdate to zdate1 dd/mm/yy.&lt;/P&gt;&lt;P&gt;           write: wa-avm_nr to zadnumber.&lt;/P&gt;&lt;P&gt;           write: wa-breite_s to zwidth.&lt;/P&gt;&lt;P&gt;           write: wa-HOEHE_S to zheight.&lt;/P&gt;&lt;P&gt;           write: wa-vavtyp.&lt;/P&gt;&lt;P&gt;       concatenate zdate1 wa-vavtyp into wa1-zdateproductcode separated by space.&lt;/P&gt;&lt;P&gt;      concatenate zwidth  zheight into wa1-zadsize separated by 'X'.&lt;/P&gt;&lt;P&gt;       w_accitab-zdateproductcode = wa1-zdateproductcode.&lt;/P&gt;&lt;P&gt;           w_accitab-zadnumber = wa-avm_nr.&lt;/P&gt;&lt;P&gt;           w_accitab-zadsize = wa1-zadsize.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;fetching the data for the last three fields &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         loop at cdata  into wac.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    case wac-kschl.&lt;/P&gt;&lt;P&gt;    when 'ZRAT'.&lt;/P&gt;&lt;P&gt;          if wac-kbetr = ' ' AND wac-kwert = ' '.&lt;/P&gt;&lt;P&gt;            continue.&lt;/P&gt;&lt;P&gt;           else.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kbetr to w_accitab-zrate.&lt;/P&gt;&lt;P&gt;                  MOVE wac-kwert to w_accitab-zsubtotal.&lt;/P&gt;&lt;P&gt;            endif.&lt;/P&gt;&lt;P&gt;      when 'ZSED'.&lt;/P&gt;&lt;P&gt;          if wac-kbetr = ' ' AND wac-kwert = ' '.&lt;/P&gt;&lt;P&gt;               continue.&lt;/P&gt;&lt;P&gt;              else.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kbetr to w_accitab-zrate.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kwert to w_accitab-zsubtotal.&lt;/P&gt;&lt;P&gt;           endif.&lt;/P&gt;&lt;P&gt;       when 'ZAC%'.&lt;/P&gt;&lt;P&gt;          if wac-kbetr = ' ' AND wac-kwert = ' '.&lt;/P&gt;&lt;P&gt;            continue.&lt;/P&gt;&lt;P&gt;             else.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kbetr to w_accitab-zrate.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kwert to w_accitab-zsubtotal.&lt;/P&gt;&lt;P&gt;             endif.&lt;/P&gt;&lt;P&gt;      when 'ZBET'.&lt;/P&gt;&lt;P&gt;        if wac-kbetr = ' ' AND wac-kwert = ' '.&lt;/P&gt;&lt;P&gt;            continue.&lt;/P&gt;&lt;P&gt;           else.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kbetr to w_accitab-zrate.&lt;/P&gt;&lt;P&gt;                 MOVE wac-kwert to w_accitab-zamount.&lt;/P&gt;&lt;P&gt;            &lt;/P&gt;&lt;P&gt;           endif.&lt;/P&gt;&lt;P&gt;      when  others.&lt;/P&gt;&lt;P&gt;          continue.&lt;/P&gt;&lt;P&gt;    endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     append accitab.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      append w_accitab to accitab.&lt;/P&gt;&lt;P&gt;     write: 20 accitab-zrate, 40 accitab-zsubtotal, 60 accitab-zamount.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; clear accitab-zamount.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  clear accitab.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    clear w_accitab.&lt;/P&gt;&lt;P&gt;    endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My second question is when the data is being checked for the condition type 'ZBET' it has to fetch the zamount data append the record to 'accitab' exit from the loop because it completes one set of record and then has to fetch the data from 'bdata' itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 16:07:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967052#M68761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T16:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967053#M68762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How to transfer the control from the inner loop to the outer loop in case of nested loops. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is I need to transfer the control to the outer loop within the case and endcase statement. while checking the last condition type 'ZBET'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any leads or suggesstions would really helpful?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 18:42:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967053#M68762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T18:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967054#M68763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know if this is all you are looking for on that last question, but the EXIT statement will kick you out of the inner loop back out to the outer loop.  You just need to put that into the case statement, wherever appropriate.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you have it, the CONTINUE statement will keep you in the inner loop - it just goes to the next record in that inner loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: John Carlson&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 19:30:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967054#M68763</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967055#M68764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you mean that if wac-kschl = 'ZBET' you want to look at the record you are currently on in WA, or do you want to look at other records in WA?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 20:02:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967055#M68764</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T20:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967056#M68765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried using ' exit' it goes out of the inner loop but reads the same data from the outer loop. the same set of records is getting pulled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The process has to  first fetch the record using the outer loop and then enters the inner loop checks for each case condition after checking for 'ZBET' condition pulls the data, from the inner loop again, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The processing of the code works like this, for every record of data pulled from the outer loop there at least two matching records in the inner loop. &lt;/P&gt;&lt;P&gt;so all the matching records in the inner loop has to be picked up for that record of the outer loop and then come out of the inner loop and fetch the next record in the outer loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used the code 'append' for BDATA(internal table for the outer loop) and cdata for the iner loop.&lt;/P&gt;&lt;P&gt;but it is not working. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know how to interlink the loops in this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you understood the process here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 20:19:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967056#M68765</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T20:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967057#M68766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This isn't clean, but I think it should work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: next_rec like sy-tabix,
      indexb   like sy-tabix,
      indexc   like sy-tabix.            

loop at bdata into wa.
  indexb = sy-tabix.
*  do some stuff
  loop at cdata into wac.
  indexc = sy-tabix.
*    do some more stuff
    if wac-kschl = 'ZBET'.
      next_rec = indexb + 1.
      read table bdata index next_rec.
*       do some more stuff
      sy-tabix = indexc.
    endif.
  endloop.
  sy-tabix = indexb.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't compiled this so check it. The main thing to do is to keep track of where you are in the tables, determine the index of the next record, read it, reset the index. (I think I've set and reset more times than necessary.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'm not sure that this is very efficient. Nested loops will read every record in the second table twice for every pass through the first one in the first table. A better approach is to use indexed reads if possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2005 20:50:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967057#M68766</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-11T20:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967058#M68767</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;If the tables BDATA and CDATA is having atleast one common field,then you can merge them.Otherwise,you cannot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at bdata into w_bdata.&lt;/P&gt;&lt;P&gt;move-corresponding w_bdata to w_output.&lt;/P&gt;&lt;P&gt;*Loop cdata if it is having multiple records for each *BDATA record.Otherwise,read cdata&lt;/P&gt;&lt;P&gt;loop cdata into w_cdata where field = w_bdata-field.&lt;/P&gt;&lt;P&gt;move-corresponding w_cdata to w_output.&lt;/P&gt;&lt;P&gt;append w_output to i_output.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2005 05:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967058#M68767</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-07-12T05:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: merging the data from two different internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967059#M68768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks Jayanti. It really helped.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2005 21:46:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/merging-the-data-from-two-different-internal-tables/m-p/967059#M68768</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-12T21:46:31Z</dc:date>
    </item>
  </channel>
</rss>

