Skip to Content

Remove Duplicate Records

Hi,

I am working on File to File scenario...I need to remove the duplicate records.

I am also refer the following thread but it's not working can someone help me...

http://scn.sap.com/thread/999261

<Records>

<Row>

<ID>10001</ID>

<Name>Praveen</Name>

<Age>22</Name>

<Gender>M</Gender>

</Row>

<Row>

<ID>11901</ID>

<Name>Raj</Name>

<Age>24</Name>

<Gender>M</Gender>

</Row>

<Row>

<ID>10001</ID>

<Name>Praveen</Name>

<Age>22</Name>

<Gender>M</Gender>

</Row>

</Records>

Target

<Records>

<Row>

<ID>10001</ID>

<Name>Praveen</Name>

<Age>22</Name>

<Gender>M</Gender>

</Row>

<Row>

<ID>11901</ID>

<Name>Raj</Name>

<Age>24</Name>

<Gender>M</Gender>

</Row>

</Records>

Regards

Gagandeep

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 12, 2012 at 09:21 AM

    Hi,

    This is very simple and can handle it in mapping,

    ID->Sort->SplitbyValue(Value change)->collapseContexts ->SplitbyValue(EveryValue)->ID

    Regards

    Baskaran K

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 12, 2012 at 09:57 AM

    Hi Gagandeep,

    You could try with this XSL-Mapping:

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="@*|node()">

    <xsl:if test="not(node()) or not(preceding-sibling::node()[.=string(current())])">

    <xsl:copy>

    <xsl:apply-templates select="@*|node()"/>

    </xsl:copy>

    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    I try with this example:

    <?xml version="1.0" encoding="UTF-8"?>

    <Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\ivm72g\Escritorio\Entrada.xsd">

    <Row>

    <ID>10001</ID>

    <Name>Praveen</Name>

    <Age>22</Age>

    <Gender>M</Gender>

    </Row>

    <Row>

    <ID>11901</ID>

    <Name>Raj</Name>

    <Age>24</Age>

    <Gender>M</Gender>

    </Row>

    <Row>

    <ID>10001</ID>

    <Name>Praveen</Name>

    <Age>22</Age>

    <Gender>M</Gender>

    </Row>

    <Row>

    <ID>10001</ID>

    <Name>Praveen</Name>

    <Age>22</Age>

    <Gender>M</Gender>

    </Row>

    <Row>

    <ID>11901</ID>

    <Name>Raj</Name>

    <Age>24</Age>

    <Gender>M</Gender>

    </Row>

    </Records>

    I obtain this output:

    <?xml version="1.0" encoding="UTF-8"?>

    <Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\ivm72g\Escritorio\Entrada.xsd">

    <Row>

    <ID>10001</ID>

    <Name>Praveen</Name>

    <Age>22</Age>

    <Gender>M</Gender>

    </Row>

    <Row>

    <ID>11901</ID>

    <Name>Raj</Name>

    <Age>24</Age>

    <Gender>M</Gender>

    </Row>

    </Records>

    I hope this works correctly always.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.