<?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: How to Insert data from Table A to Table B in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555077#M251488</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kumar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure of the details of table  A &amp;amp; B.&lt;/P&gt;&lt;P&gt;If they have the same structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try -    INSERT LINES OF itabA into itabB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could use DELETE ADJACENT DUPLICATES FROM itabB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to find other options from HELP for INSERT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg Kern&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Oct 2006 20:09:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-06T20:09:55Z</dc:date>
    <item>
      <title>How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555074#M251485</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;I have to insert data from Table A into Table B. &lt;/P&gt;&lt;P&gt;Table A is having 100 records and table B is having 10000 records.&lt;/P&gt;&lt;P&gt;Condition is if data in Table A is not in table B then I have to insert into Table B or else I have to skip that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me with sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance and points are awarded for usefull answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kumar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Oct 2006 19:57:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555074#M251485</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-06T19:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555075#M251486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THere are a couple ways of doing this.  Here is one simple way.  Of course, this is assuming that the tables have exactly the same structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: itaba type table of ztaba with header line.
data: itabb type table of ztabb with header line.

select * into table itaba from ztaba.
select * into table itabb from ztabb.

loop at itaba.

read table itabb with key fld1 = itaba-fld1
                          fld2 = itaba-fld2.
if sy-subrc &amp;lt;&amp;gt; 0.
 insert ztabb from itaba.
endif.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Oct 2006 20:02:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555075#M251486</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-06T20:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555076#M251487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kumar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that tables A and B have the same structure you can use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_s_itab_di.  
INCLUDE TYPE struc_a.
TYPES: CHIND  TYPE bu_chind.
TYPES: END OF ty_s_itab_di.
TYPES: ty_t_itab_di  TYPE STANDARD TABLE OF ty_s_itab_di                      
WITH DEFAULT KEY.
DATA:    gt_itab_old  TYPE ty_t_itab_di,
gt_itab_new TYPE ty_t_itab_di.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Very important: sort you itabs either by all key fields or by all fields.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call function &amp;lt;b&amp;gt;CHANGEDOCUMENT_PREPARE_TABLES&amp;lt;/b&amp;gt; with the following parameters:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;- CHECK_INDICATOR = ' ' &lt;/P&gt;&lt;P&gt;- TABLE_NEW = gt_Itab_new&lt;/P&gt;&lt;P&gt;- TABLE_OLD = gt_itab_old&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'. Modified entries are indicated by CHIND = 'U'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Oct 2006 20:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555076#M251487</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-10-06T20:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555077#M251488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kumar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure of the details of table  A &amp;amp; B.&lt;/P&gt;&lt;P&gt;If they have the same structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try -    INSERT LINES OF itabA into itabB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could use DELETE ADJACENT DUPLICATES FROM itabB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may be able to find other options from HELP for INSERT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg Kern&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Oct 2006 20:09:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555077#M251488</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-06T20:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555078#M251489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kumar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can go with the solution provided by Rich if the two tables are related .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; or You can choose the follwing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Assume ITAB JTAB having the data .&lt;/P&gt;&lt;P&gt; use the sample code&lt;/P&gt;&lt;P&gt;  APPEND LINES OF ITAB[] TO JTAB[].&lt;/P&gt;&lt;P&gt;  SORT jtab.&lt;/P&gt;&lt;P&gt;  delete adjacent duplicates from jtab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Oct 2006 04:19:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555078#M251489</guid>
      <dc:creator>shishupalreddy</dc:creator>
      <dc:date>2006-10-07T04:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Insert data from Table A to Table B</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555079#M251490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kumar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May the following code help u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentials before using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the two itabs should be sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: bkpf_index LIKE sy-tabix,&lt;/P&gt;&lt;P&gt;      bseg_index LIKE sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR: bkpf_reads,&lt;/P&gt;&lt;P&gt;         bseg_reads.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SORT: bkpf_tab BY bukrs belnr gjahr,&lt;/P&gt;&lt;P&gt;        bseg_tab BY bukrs belnr gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  bseg_index = 1.&lt;/P&gt;&lt;P&gt;  LOOP AT bkpf_tab&lt;/P&gt;&lt;P&gt;    INTO bkpf_lin.&lt;/P&gt;&lt;P&gt;    bkpf_reads = bkpf_reads + 1.&lt;/P&gt;&lt;P&gt;    LOOP AT bseg_tab INTO bseg_lin FROM bseg_index.&lt;/P&gt;&lt;P&gt;      IF bseg_lin-bukrs &amp;lt;&amp;gt; bkpf_lin-bukrs OR&lt;/P&gt;&lt;P&gt;         bseg_lin-belnr &amp;lt;&amp;gt; bkpf_lin-belnr OR&lt;/P&gt;&lt;P&gt;         bseg_lin-gjahr &amp;lt;&amp;gt; bkpf_lin-gjahr.&lt;/P&gt;&lt;P&gt;        bseg_index = sy-tabix.&lt;/P&gt;&lt;P&gt;        EXIT.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        bseg_reads = bseg_reads + 1.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Oct 2006 05:52:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-data-from-table-a-to-table-b/m-p/1555079#M251490</guid>
      <dc:creator>former_member235542</dc:creator>
      <dc:date>2006-10-07T05:52:51Z</dc:date>
    </item>
  </channel>
</rss>

