on 04-20-2016 7:01 AM
Hello,
I have a very simple requirement to map Idoc-XML to Idoc using XSLT mapping.
There are no mapping rules as such it is pass through but only one condition as follows.
I need to add value "PP" into <MESFCT> tag in IDOC when ever the 1st QUALF field from segment E1EDK02 contains value 001 otherwise it will be TT. I have written the following code but it is not working. could you please help me?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="IDOC/EDI_DC40">
<IDOCTYP>abc</IDOCTYP>
<MESTYP>INVOIC</MESTYP>
<SNDPOR>pqr</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>INVOICE</SNDPRN>
<RCVPOR>xyz</RCVPOR>
<RCVPRT>XX</RCVPRT>
<RCVPRN>RCVPRN####</RCVPRN>
<MESCOD>WF</MESCOD>
<xsl:if test="position() = '1'">
<xsl:variable name="QLF" select="/INVOIC02/IDOC/E1EDK02/QUALF"/>
<xsl:variable name="Value" select="'001'"/>
<xsl:choose>
<xsl:when test="$QLF=$Value">
<MESFCT>PP</MESFCT>
</xsl:when>
<xsl:otherwise>
<MESFCT>TT</MESFCT>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Hi Rahul,
The function position() you should use it inside a for-each instruction, check the Example 2 here.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.