on 04-16-2019 6:28 PM
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 this using XSLT mapping?
I tried asking the query in SAP PO and was suggested to use XSLT mapping. Hence posting the question in this forum.
Thank you
Hi Abhishek,
Below XSLT will do this transform.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://test.com">
<xsl:template match="/">
<ns:MT_Employee>
<Employee>
<EmployeeDetails>
<xsl:for-each select="/ns:MT_Employee/Records/row">
<Employee>
<xsl:variable name="EmpID">
<xsl:value-of select="EmpID"/>
</xsl:variable>
<EmpID>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/EmpID"/>
</EmpID>
<Record>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/Record"/>
</Record>
<Area>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/Area"/>
</Area>
<SubArea>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/SubArea"/>
</SubArea>
<Subsection>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/Subsection"/>
</Subsection>
<FirstName>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/FirstName"/>
</FirstName>
<LastName>
<xsl:value-of select="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]/LastName"/>
</LastName>
</Employee>
</xsl:for-each>
</EmployeeDetails>
</Employee>
</ns:MT_Employee>
</xsl:template>
</xsl:stylesheet>
Paste your XML next time instead of screenshot.
Regards,
Yatan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhishek!
First of all, you should use some XSLT debugging tool with profiling possiblities (for example, Oxygen XML Editor) to find bottle necks.
By the way, first thing I would try is to store:
<xsl:value-ofselect="/ns:MT_Employee/EmployeeDetails/Employee[EmpID=$EmpID]
to variable for current row and use that variable to fetch the needed child values instead of repeating the search through entire XML tree for every target element.
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,
9K is a big XML, however 30 min is a big time to process it, you can try using groovy script or standard mapping of CPI to see if the performance is better.
XSLT is not the default mapping for CPI, so we can not expect good performance.
Regards,
Yatan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
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.