<?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: Sorting and deleting in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760853#M1116307</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I have an internal table &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; itab&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; a      b &lt;/P&gt;&lt;P&gt;&amp;gt; 40    44&lt;/P&gt;&lt;P&gt;&amp;gt; 40    55&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I want to delete the duplicates of column A&lt;/P&gt;&lt;P&gt;&amp;gt; I need row 2 because it is having hghest value in column B&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Shilpa,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Lets analyse the problem first. You need to delete the duplicate entries from an internal table provided that the entry which remains, is the entry with highest value for field B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus we can use the ABAP keyword SORT. You can sort the table in descending order and the use the ABAP ststement DELETE DUPLICATE. Here is the code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* The below code sorts the table in such a way that the table looks like follows:-
* A    B
*40   55
*40   44
SORT itab by a b descending.

*Next delete duplicates
DELETE ADJACENT DUPLICATES FROM itab COMPARING A .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Nov 2008 14:33:34 GMT</pubDate>
    <dc:creator>raviprakash</dc:creator>
    <dc:date>2008-11-14T14:33:34Z</dc:date>
    <item>
      <title>Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760848#M1116302</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;&lt;/P&gt;&lt;P&gt;I have an internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a      b &lt;/P&gt;&lt;P&gt;40    44&lt;/P&gt;&lt;P&gt;40    55&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to delete the duplicates of column A&lt;/P&gt;&lt;P&gt;I need row 2 because it is having hghest value in column B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:07:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760848#M1116302</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-14T14:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760849#M1116303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;F1 is a good tool to start with. &lt;/P&gt;&lt;P&gt;Plus You already have the keywords with you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:09:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760849#M1116303</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-14T14:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760850#M1116304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No it is a internal table of diffrent table fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:11:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760850#M1116304</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-14T14:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760851#M1116305</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;SORT ITAB BY A ASCENDING B DESCENDING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this way the firt row as soon as the value of A is changed is the row you need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT ITAB.
  IF ITAB-A = OLD_A.
    DELETE ITAB.
  ENDIF.
  OLD_A = ITAB-A.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:12:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760851#M1116305</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-14T14:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760852#M1116306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alternatively you can also &lt;/P&gt;&lt;P&gt;Use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab by A ascending B descending&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE adjacent duplicates comparing A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:27:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760852#M1116306</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-14T14:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting and deleting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760853#M1116307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I have an internal table &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; itab&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; a      b &lt;/P&gt;&lt;P&gt;&amp;gt; 40    44&lt;/P&gt;&lt;P&gt;&amp;gt; 40    55&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I want to delete the duplicates of column A&lt;/P&gt;&lt;P&gt;&amp;gt; I need row 2 because it is having hghest value in column B&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Shilpa,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Lets analyse the problem first. You need to delete the duplicate entries from an internal table provided that the entry which remains, is the entry with highest value for field B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus we can use the ABAP keyword SORT. You can sort the table in descending order and the use the ABAP ststement DELETE DUPLICATE. Here is the code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* The below code sorts the table in such a way that the table looks like follows:-
* A    B
*40   55
*40   44
SORT itab by a b descending.

*Next delete duplicates
DELETE ADJACENT DUPLICATES FROM itab COMPARING A .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2008 14:33:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-and-deleting/m-p/4760853#M1116307</guid>
      <dc:creator>raviprakash</dc:creator>
      <dc:date>2008-11-14T14:33:34Z</dc:date>
    </item>
  </channel>
</rss>

