<?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 Duplicates from internal table with object references in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647946#M610148</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;What about creating your internal table with index....so you wont be able to repeat elements inside the IT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gabriel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2007 16:17:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-21T16:17:05Z</dc:date>
    <item>
      <title>Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647944#M610146</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;How can I delete duplicates from an internal table in ABAP OO based on the value of one of the attributes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a method, with the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
......
  LOOP AT me-&amp;gt;business_document_lines INTO l_add_line.

    CREATE OBJECT ot_line_owner
      EXPORTING
        i_user      = l_add_line-&amp;gt;add_line_data-line_owner
        i_busdoc = me-&amp;gt;business_document_id.

      APPEND ot_line_owner TO e_line_owners.

  ENDLOOP.
.....
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e_line_owners are defined as a table containing only object references.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of the attribute of the object in the table is called USER. And I would like to do a "delete ADJACENT DUPLICATES FROM e_line_owners", based on that attribute. &lt;/P&gt;&lt;P&gt;How can do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten Nielsen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 14:21:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647944#M610146</guid>
      <dc:creator>morten_nielsen</dc:creator>
      <dc:date>2007-08-21T14:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647945#M610147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I think you will have to do it manually...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Store the value of the attrib of the first line of the table in a temp value lv_attrib_old.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP starting a the second line INTO lv_line_new.&lt;/P&gt;&lt;P&gt;  check if the value of the attrib in the same.&lt;/P&gt;&lt;P&gt;    In this case delete the line.&lt;/P&gt;&lt;P&gt;  else&lt;/P&gt;&lt;P&gt;    lv_attrib_old = lv_line_new-&amp;gt;attrib.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you can do it when you create your table so you don't add it when the attribute has the same value as the old one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 16:09:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647945#M610147</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-21T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647946#M610148</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;What about creating your internal table with index....so you wont be able to repeat elements inside the IT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gabriel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 16:17:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647946#M610148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-21T16:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647947#M610149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Morten&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that the instance attribute is &amp;lt;b&amp;gt;public &amp;lt;/b&amp;gt;you could try to use the following coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  SORT e_line_owners BY table_line-&amp;gt;user.
  DELETE ADJACENT DUPLICATES FROM e_line_owners
    COMPARING table_line-&amp;gt;user.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I am not really sure (cannot test myself) whether &amp;lt;b&amp;gt;TABLE_LINE&amp;lt;/b&amp;gt; can be used together with SORT and DELETE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  DATA:
     ld_idx    TYPE sy-tabix.

  LOOP AT e_line_owners INTO ls_line.
    ld_idx = syst-tabix + 1.

    LOOP AT e_line_owners TRANSPORTING NO FIELDS FROM ld_idx
                   WHERE ( table_line-&amp;gt;user = ls_line-&amp;gt;user ).
      DELETE e_line_owners INDEX syst-tabix.
    ENDLOOP.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Tue, 21 Aug 2007 19:06:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647947#M610149</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-08-21T19:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647948#M610150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Uwe !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first suggestion worked like a dream &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 20:15:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647948#M610150</guid>
      <dc:creator>morten_nielsen</dc:creator>
      <dc:date>2007-08-21T20:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Duplicates from internal table with object references</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647949#M610151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Morten&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for this feedback. I have seen and used TABLE_LINE together with READ TABLE and LOOP AT yet it is good to know that it works for the other statements as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 21:08:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-duplicates-from-internal-table-with-object-references/m-p/2647949#M610151</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-08-21T21:08:41Z</dc:date>
    </item>
  </channel>
</rss>

