cancel
Showing results for 
Search instead for 
Did you mean: 

Removing duplicates records based on email in sap cpi

0 Kudos

Hi All,

We have requirement of removing the duplicate records based on email. In email, we might have different type of text like, sometimes all values in caps or sometimes all values in small or sometimes first letter caps and remaining values in small like that. So, to compare the duplicate values, we need to convert the values either to small or caps just for duplicate comparison.

Previously, We have removed the duplicates with Employee ID. So, I have used below XSLT mapping.

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

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

<xsl:output method="xml" indent="yes"/>

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

<xsl:copy>

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

</xsl:copy>

</xsl:template>

<xsl:template match="root">

<root>

<xsl:for-each-group select="USER"

group-by="EmployeeID">

<xsl:apply-templates select="."/>

</xsl:for-each-group>

</root>

</xsl:template>

</xsl:stylesheet>

Currently, I might get the emails like below.michel.hari@xyz.comMichel.HARI@xyz.com
Source payload might look like below and taget also need same structure<root> <USER> <EmployeeID>1234</EmployeeID> <email>michel.hari@xyz.com</email> </USER></root>
So please help me in figuring out a way to remove the duplicates records of this user considering both records have same data excepts the caps and small letters.

View Entire Topic
anoop-jose
Participant
0 Kudos

Hi Mohanty,

Can you please try below one.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
   <xsl:strip-space elements="*"/>
   <xsl:template match="node()|@*">
      <xsl:copy>
         <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
   </xsl:template>
   
   <xsl:template match="root">
      <root>
         <xsl:for-each-group select="USER" group-by="lower-case(email)">
            <xsl:apply-templates select="."/>
         </xsl:for-each-group>
      </root>
   </xsl:template>
</xsl:stylesheet>

Thanks So much, Anoop.

It worked for me.