<?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: Logic for populating internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813839#M657902</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Premraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You loop at it_bseg_ven and read table it_bseg with the keys u mentioned.&lt;/P&gt;&lt;P&gt;If record not found in it_bseg (SY_SUBRC &amp;lt;&amp;gt; 0); append that record in it_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it wil solve your problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pankaj Sharma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 30 Sep 2007 10:27:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-30T10:27:07Z</dc:date>
    <item>
      <title>Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813838#M657901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abapers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two internal tables it_bseg and it_bseg_ven with header lines. the key fields common to these two tables are bukrs, belnr and gjahr. My requirement is to move records of it_bseg_ven to it_bseg which are not there in it_bseg by comparing key fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I coded this way. but 'ne' is not supported in read. how can i achieve this. because no.of records are more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; LOOP AT it_bseg.&lt;/P&gt;&lt;P&gt;    READ TABLE it_bseg_ven WITH KEY bukrs ne it_bseg-bukrs&lt;/P&gt;&lt;P&gt;                                    belnr ne it_bseg-belnr&lt;/P&gt;&lt;P&gt;                                    gjahr ne it_bseg-gjahr.&lt;/P&gt;&lt;P&gt;    IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;      MOVE it_bseg_ven-bukrs TO it_bseg-bukrs.&lt;/P&gt;&lt;P&gt;      MOVE it_bseg_ven-belnr TO it_bseg-belnr.&lt;/P&gt;&lt;P&gt;      MOVE it_bseg_ven-gjahr TO it_bseg-gjahr.&lt;/P&gt;&lt;P&gt;      APPEND it_bseg.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  SORT it_bseg BY bukrs belnr gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pointa are sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Premraj Cheguri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 10:21:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813838#M657901</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-30T10:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813839#M657902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Premraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You loop at it_bseg_ven and read table it_bseg with the keys u mentioned.&lt;/P&gt;&lt;P&gt;If record not found in it_bseg (SY_SUBRC &amp;lt;&amp;gt; 0); append that record in it_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it wil solve your problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pankaj Sharma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 10:27:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813839#M657902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-30T10:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813840#M657903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why don't you do it the other way around? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_bseg_ven.&lt;/P&gt;&lt;P&gt;READ TABLE it_bseg TRANSPORTING NO FIELDS&lt;/P&gt;&lt;P&gt;WITH KEY bukrs = it_bseg_ven-bukrs&lt;/P&gt;&lt;P&gt;         belnr = it_bseg_ven-belnr&lt;/P&gt;&lt;P&gt;         gjahr = it_bseg_ven-gjahr.&lt;/P&gt;&lt;P&gt;IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;MOVE it_bseg_ven-bukrs TO it_bseg-bukrs.&lt;/P&gt;&lt;P&gt;MOVE it_bseg_ven-belnr TO it_bseg-belnr.&lt;/P&gt;&lt;P&gt;MOVE it_bseg_ven-gjahr TO it_bseg-gjahr.&lt;/P&gt;&lt;P&gt;APPEND it_bseg.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 10:31:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813840#M657903</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-30T10:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813841#M657904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah i can do this but the problem is there could be 5000 records in it_bseg and it_bseg_ven. almost many records are common between these two tables. because of not doing correct archiving for the database table bseg some records are missing in it_bseg. so is there any way to move records which are not there with minimal execution time without effecting performance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help me ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Radhika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 10:32:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813841#M657904</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-30T10:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813842#M657905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The TRANSPORTING NO FIELDS addition checks for existance, and doesn't have the overhead of moving the record to the work area. Much quicker &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 10:37:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813842#M657905</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-30T10:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Logic for populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813843#M657906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Premraj ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since release 4.5 you can LOOP ASSIGNING &amp;lt;field-symbol&amp;gt;. This removes the overhead of moving every table body line to the header line completely. Especially for tables with that much fields as BSEG it will ibrease processing time 5 to 10 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may do like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
field-symbols:
  &amp;lt;bseg&amp;gt; like line of it_bseg[].
sort:
  it_bseg_ven by bukrs belnr jhahr.
loop at it_bseg assigning &amp;lt;bseg&amp;gt;. 
* check if record is already present
  read table it_bseg_ven transporting no fields
    with key 
    bukrs = &amp;lt;bseg&amp;gt;-bukrs
    belnr = &amp;lt;bseg&amp;gt;-belnr
    gjahr = &amp;lt;bseg&amp;gt;-gjahr
    binary search.
  check sy-subrc = 0.
* yes this record is already in it_bseg - don't need
  delete it_bseg_ven index sy-tabix.
endloop.
append lines of it_bseg_ven to it_bseg. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this will be pretty fast - any better idea around?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or like this: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
append lines of it_bseg_ven to it_bseg.
sort it_bseg.
delete adjacent duplicates from it_bseg comparing bukrs belnr gjahr.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just depend on if all other fields in the 2 internal tables are just the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2007 12:49:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/logic-for-populating-internal-table/m-p/2813843#M657906</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2007-09-30T12:49:09Z</dc:date>
    </item>
  </channel>
</rss>

