<?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: Getting unique values from internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888303#M1479624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, with the restriction of copy and modification on original internal table you got no choice but to loop through each record. I would suggest loop through records using field symbol and use COLLECT statement (with some consideration) to get unique records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pawan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 May 2010 12:44:26 GMT</pubDate>
    <dc:creator>Pawan_Kesari</dc:creator>
    <dc:date>2010-05-04T12:44:26Z</dc:date>
    <item>
      <title>Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888295#M1479616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From time to time I hit this problem and so far I havn't found any nice solution. I've an internal table with several fields. I would like to get all unique values for one (or several) of these fields. However let say that this table has a lot of entries so making a copy is not an option. Also changing this table in any way is forbiden.&lt;/P&gt;&lt;P&gt;For example for table below I would like to get all unique values for field Number. In this case it would be 1,2,3,4.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Name  | Number |
name1 | 1|
name2 | 2|
name3 | 2|
name4 | 3|
name5 | 4|
name5 | 3|
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can anyone propose me better solution than going in the loop through all entries in table? Maybe there is some ABAP functionality that I don't know about?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Marcin Cholewczuk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:08:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888295#M1479616</guid>
      <dc:creator>marcin_cholewczuk</dc:creator>
      <dc:date>2010-05-04T12:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888296#M1479617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heard about DELETE ADJACENT DUPLICATES ? Read the SAP documentation for further details&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"Sort Internal Table based on the fields you want to delete the duplicate fields
SORT ITAB BY NUMBER. 

DELETE ADJACENT DUPLICATES ROM ITAB COMPARING NUMBER.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on May 4, 2010 5:43 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:12:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888296#M1479617</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-05-04T12:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888297#M1479618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Loop at the table and use event &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AT NEW number&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will only stop at new numbers. This will work if the table is sorted. If your table isn't sorted, then you could start a paralel internal table containing the numbers that already appeared, and check againts it to see if it already appeared, this table could be of sorted type. A final tip, if you use AT NEW remeber to close it with an ENDAT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:15:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888297#M1479618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-04T12:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888298#M1479619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use &lt;STRONG&gt;DELETE ADJACENT DUPLICATES&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Delete adjacent duplicates-SAP Help|http://help.sap.com/saphelp_nw04/helpdata/en/06/aafd54fc4011d195280000e8353423/content.html]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:18:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888298#M1479619</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-04T12:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888299#M1479620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Yes I heard about DELETE ADJACENT DUPLICATES, but I also wrote that table shouldn't be changed in any way. So this is not good solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. No, this table is not sorted. You can also see this in example data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Never less thank you for your answers. Anybody have other ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:19:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888299#M1479620</guid>
      <dc:creator>marcin_cholewczuk</dc:creator>
      <dc:date>2010-05-04T12:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888300#M1479621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly do you want to achieve ? Why can't you sort the table entries ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you be more specific about your requirement ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888300#M1479621</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-05-04T12:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888301#M1479622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Maybe there is some ABAP functionality that I don't know about&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If &lt;STRONG&gt;DELETE ADJACENT DUPLICATES&lt;/STRONG&gt; is not the case. You can code something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop your Internal table. Use &lt;STRONG&gt;READ TABLE&lt;/STRONG&gt; statement to fetch the first number and store it in a variable.&lt;/P&gt;&lt;P&gt;Again for the second time the it reads the second and compare it with the first one stored. If found equal delete or else continue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:29:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888301#M1479622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-04T12:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888302#M1479623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Going more into details is rather pointless and would take a lot of time to explain background. Just as I said I can't modify this table in any way and I want all unique values that occured in one of fields. Let's say that if I sort this table I won't be able to restore it to previous order which is important for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you  Mishra for answer but as I wrote in first message I would like to have nicer solution than going through all entries in loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:31:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888302#M1479623</guid>
      <dc:creator>marcin_cholewczuk</dc:creator>
      <dc:date>2010-05-04T12:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888303#M1479624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, with the restriction of copy and modification on original internal table you got no choice but to loop through each record. I would suggest loop through records using field symbol and use COLLECT statement (with some consideration) to get unique records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pawan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 12:44:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888303#M1479624</guid>
      <dc:creator>Pawan_Kesari</dc:creator>
      <dc:date>2010-05-04T12:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888304#M1479625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can't change the original table in any way and can't duplicate it, the problem just can't be solved. Because you need to sort an internal table to apply any algorithm which would look up unique values, or, if you can't sort, you need to have an extra table to keep unique entries which would be found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, Eugene.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 13:21:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888304#M1479625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-04T13:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting unique values from internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888305#M1479626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Let's say that if I sort this table I won't be able to restore it to previous order which is important for me&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;True...If you sort the table you won't be able to restore. So the only option is to copy/move all the records into another table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sorting&lt;/STRONG&gt; If you need to retrive unique values. I don't think without sorting the table would be a nice idea and proper programming to proceed ahead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding logic, &lt;SPAN __default_attr="green" __jive_macro_name="color"&gt; as replied earlier&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Either we can go with &lt;STRONG&gt;DELETE ADJACENT DUPLICATES&lt;/STRONG&gt; or proceed as replied in my earlier post. There might be number of algorithms to resolve this. But we cannot go ahead without sorting or looping.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 13:57:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-unique-values-from-internal-table/m-p/6888305#M1479626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-04T13:57:37Z</dc:date>
    </item>
  </channel>
</rss>

