on 04-16-2019 6:54 AM
Dear Experts,
I have a mapping requirement to merge employee data from one segment (Records) into corresponding employee record from other segment (EmployeeDetails). This is shown in the attached image with sample data:
For ex. : For EmployeeDetails > Employee > EmpID = 1111 the values for Area and SubArea should be mapped from Records > row > Section and SubSection respectively.
There will be 1000s of records for which such a merging needs to be done with each EmpID repeating only once.
If there is no corresponding value found in Records > row for an user then the values from EmployeeDetails > Employee should be sent as is.
Any inputs on how this can be achieved in mapping?
Thank you!
Hi Abhishek!
This can be done by using UDF(user defined function) as well in Graphical Mapping. I have attached the UDF code below and also mapping parts.
for(int i=0;i<in1.length;i++) //in1.length-- count of employee in employee details
{
for(int j=0;j<input1.length;j++) //input1.length-- count of employee in records
{
if(in2[i]!=input1[j])
{
if(j==input1.length-1)
{
out1.addValue(in1[i]);
out2.addValue(in2[i]);
out3.addValue(in3[i]);
out4.addValue(in4[i]);
out5.addValue(in5[i]);
out6.addValue(in6[i]);
}
}
else if(in2[i]==input1[j])
{
out1.addValue(in1[i]);
out2.addValue(in2[i]);
out3.addValue(in3[i]);
out4.addValue(in4[i]);
out5.addValue(input2[j]);
out6.addValue(input3[j]);
break;
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhishek!
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://test.com"
version="1.0">
<xsl:template match="/">
<ns0:MT_Employee_Out>
<EmployeeDetails>
<xsl:apply-templates select="/ns0:MT_Employee/Employee_Details/Employee"/>
</EmployeeDetails>
</ns0:MT_Employee_Out>
</xsl:template>
<xsl:template match="Employee">
<xsl:variable name="id" select="EmpID"/>
<Employee>
<EmpID><xsl:value-of select="EmpID"/></EmpID>
<Record><xsl:value-of select="Record"/></Record>
<FirstName><xsl:value-of select="FirstName"/></FirstName>
<LastName><xsl:value-of select="LastName"/></LastName>
<xsl:apply-templates select="/ns0:MT_Employee/Records/row[EmpID = $id]"/>
</Employee>
</xsl:template>
<xsl:template match="row">
<Area><xsl:value-of select="Section"/></Area>
<SubArea><xsl:value-of select="SubSection"/></SubArea>
</xsl:template>
</xsl:stylesheet>
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhishek!
Your requirement could be easily fulfilled by using XSL transformation.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.