<?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: Delete duplicate from internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933152#M691133</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort itab by cno catg1 descending.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from itab comparing cno.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vasu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Oct 2007 08:44:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-09T08:44:36Z</dc:date>
    <item>
      <title>Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933150#M691131</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 a query on how to remove the duplicates from an internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My internal table data is as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cno    Catg1  Catg2 &lt;/P&gt;&lt;P&gt;01       0         1000&lt;/P&gt;&lt;P&gt;01      2000         0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get only one record as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;01   2000  1000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to  get the result.&lt;/P&gt;&lt;P&gt;I tried sorted by cno and used delete duplicates but it was not helpful.&lt;/P&gt;&lt;P&gt;Is there any other alternative to get this done&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;Priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:42:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933150#M691131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T08:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933151#M691132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You Can use Collect Statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLLECT is used to Summarize the Data in internal table while adding the rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Collect &amp;lt;wa&amp;gt; into &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement compares the Non-numeric(Type C,N,D,T,X,String) fields of the work area with the Existing rows in the internal table. that means all the Non-numeric fields will act as key (For Eg Matno, Plant)&lt;/P&gt;&lt;P&gt;If a row is found with the same key: &lt;/P&gt;&lt;P&gt;It will add the Numeric fields instead of creating a new row.&lt;/P&gt;&lt;P&gt;If a row is not found with the same key: &lt;/P&gt;&lt;P&gt;It will create a new row like Append.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF ITAB1 OCCURS 0,&lt;/P&gt;&lt;P&gt;MATNR TYPE MARD-MATNR,&lt;/P&gt;&lt;P&gt;WERKS TYPE MARD-WERKS,&lt;/P&gt;&lt;P&gt;LABST TYPE MARD-LABST,&lt;/P&gt;&lt;P&gt;END OF ITAB.&lt;/P&gt;&lt;P&gt;DATA :WA LIKE ITAB1.&lt;/P&gt;&lt;P&gt;DATA: ITAB2 LIKE ITAB1 OCCURS 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT MATNR WERKS LABST FROM MARD INTO TABLE ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;COLLECT WA INTO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the contents of both ITAB1 AND ITAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:43:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933151#M691132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T08:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933152#M691133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort itab by cno catg1 descending.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from itab comparing cno.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vasu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:44:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933152#M691133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T08:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933153#M691134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;      try to sort the internal table based on the three field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Soirt it_tab1 by cno catg1 catg2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM lt_tab1 comparing cno catg1 catg2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or try this logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table it_tab1 into ls_tab1_temp index 1.&lt;/P&gt;&lt;P&gt;l_count = 0.&lt;/P&gt;&lt;P&gt;loop at it_tab1 into ls_tab1.&lt;/P&gt;&lt;P&gt; if ls_tab1-cno eq ls_temp_temp-cno. &amp;lt;&amp;lt;add the conditions&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;    l_count = l_count + 1.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if l_count GT 1.&lt;/P&gt;&lt;P&gt; delete it_tab1 from ls_tab1_temp  index sy-tabix.&lt;/P&gt;&lt;P&gt;clear l_count.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;ls_tab1_temp = ls_tab1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Niyaz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:52:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933153#M691134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T08:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933154#M691135</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;try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab into watab.&lt;/P&gt;&lt;P&gt;read table itab into watab1 where cno = watab-cno.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;move : watab1-cno to watab2-cno.&lt;/P&gt;&lt;P&gt;if watab-catg1 LT watab1-catg1.&lt;/P&gt;&lt;P&gt;move : watab1-catg1 to watab2-catg1.&lt;/P&gt;&lt;P&gt;append itab1 from watab2.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;move : watab-catg1 to watab2-catg1.&lt;/P&gt;&lt;P&gt;append itab1 from watab2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if watab-catg2 LT watab1-catg2.&lt;/P&gt;&lt;P&gt;move : watab1-catg2 to watab2-catg2.&lt;/P&gt;&lt;P&gt;modify itab1 from watab2.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;move : watab-catg2 to watab2-catg2.&lt;/P&gt;&lt;P&gt;modify itab1 from watab2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:57:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933154#M691135</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2007-10-09T08:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933155#M691136</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;   Go through example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     DATA: BEGIN OF connection, &lt;/P&gt;&lt;P&gt;        cityfrom TYPE spfli-cityfrom, &lt;/P&gt;&lt;P&gt;        cityto   TYPE spfli-cityto, &lt;/P&gt;&lt;P&gt;        distid   TYPE spfli-distid, &lt;/P&gt;&lt;P&gt;        distance TYPE spfli-distance, &lt;/P&gt;&lt;P&gt;      END OF connection. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     DATA connection_tab LIKE SORTED TABLE OF connection &lt;/P&gt;&lt;P&gt;                                     WITH NON-UNIQUE KEY cityfrom cityto &lt;/P&gt;&lt;P&gt;                                        distid distance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       SELECT cityfrom cityto distid distance &lt;/P&gt;&lt;P&gt;                              FROM spfli &lt;/P&gt;&lt;P&gt;                              INTO TABLE connection_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        DELETE ADJACENT DUPLICATES FROM connection_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Reward if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:58:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933155#M691136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T08:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933156#M691137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check it out with delete adjacent duplicate records &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting Adjacent Duplicate Entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To delete adjacent duplicate entries use the following statement: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATE ENTRIES FROM &amp;lt;itab&amp;gt; &lt;/P&gt;&lt;P&gt;                                  [COMPARING &amp;lt;f1&amp;gt; &amp;lt;f 2&amp;gt; ... &lt;/P&gt;&lt;P&gt;                                             |ALL FIELDS].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system deletes all adjacent duplicate entries from the internal table &amp;lt;itab&amp;gt;. Entries are duplicate if they fulfill one of the following compare criteria:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines. &lt;/P&gt;&lt;P&gt;If you use the addition COMPARING &amp;lt;f1&amp;gt; &amp;lt;f 2&amp;gt; ... the contents of the specified fields &amp;lt;f 1 &amp;gt; &amp;lt;f 2 &amp;gt; ... must be identical in both lines. You can also specify a field &amp;lt;f i &amp;gt; dynamically as the contents of a field &amp;lt;n i &amp;gt; in the form (&amp;lt;n i &amp;gt;). If &amp;lt;n i &amp;gt; is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length. &lt;/P&gt;&lt;P&gt;If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical. &lt;/P&gt;&lt;P&gt;You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 09:16:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933156#M691137</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-09T09:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933157#M691138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no u cant use delete adjacent duplicates and get the o/p u needed in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one solution is collect statement, while inserting record itself, if u use collect u can get the o/p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or else u have to write some logic&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2007 09:28:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933157#M691138</guid>
      <dc:creator>hymavathi_oruganti</dc:creator>
      <dc:date>2007-10-09T09:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933158#M691139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all of u , By using the collect statement i am able to get the desired result&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2007 04:36:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933158#M691139</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-10T04:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933159#M691140</link>
      <description>&lt;P&gt;Hi ABAPers,&lt;/P&gt;&lt;P&gt;You may use following logic to delete duplicate entries from an internal table and show in the output the specific entry which is duplicate as an error:&lt;/P&gt;&lt;P&gt;Let say ITAB1[ ] has all your data. Sort it based on key and then assign it to another temporary table ITAB2[ ].&lt;/P&gt;&lt;P&gt;i.e. ITAB1[ ] = ITAB2[ ].&lt;/P&gt;&lt;P&gt;Now, DELETE ADJACENT DUPLICATES from table ITAB2[ ] comparing the key. Now ITAB2[ ] has all but unique entries from ITAB1 [ ] while your original table ITAB1[ ] has all the entries (Including duplicate ones).&lt;/P&gt;&lt;P&gt;Now, LOOP AT ITAB1[ ] INTO DATA(LWA_ITAB1). (Loop at original table)&lt;/P&gt;&lt;P&gt;*** "Start of Comment" Inside this LOOP, READ ITAB2[ ] and delete it for that particular entry If   SY-SUBRC = 0 (If read is successful). This deletion would remove that particular unique entry from ITAB2[ ] and now if it's READ again for the same entry it should throw an error (Sy-subrc &amp;lt;&amp;gt; 0) and at the same time it would also mean that it's being read for a duplicate entry from ITAB1[ ].&lt;/P&gt;&lt;P&gt;So now, if next time in ITAB1[ ]LOOP sy-subrc &amp;lt;&amp;gt; 0, this would mean that the current entry is duplicate as it was already found once and hence deleted. *** End of Comment&lt;/P&gt;&lt;P&gt;** PSEUDOCODE&lt;/P&gt;&lt;P&gt;READ TABLE ITAB2[ ] INTO DATA(lwa_itab2) WITH KEY KEY1 = .LWA_ITAB1-KEY1.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;DELETE ITAB2[ ] WHERE KEY1 = LWA_ITAB1-KEY1.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;Throw an error or append error to return table saying KEY1 has duplicate entries.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 16:38:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicate-from-internal-table/m-p/2933159#M691140</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-11-01T16:38:42Z</dc:date>
    </item>
  </channel>
</rss>

