cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT query related to Idoc-XML to IDOC scenario

r_s_kulkarni11
Participant
0 Kudos

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>

Accepted Solutions (0)

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi Rahul,

The function position() you should use it inside a for-each instruction, check the Example 2 here.

Regards.

r_s_kulkarni11
Participant
0 Kudos

Hello Inaki,

Tried with for each also but it is not giving the expected output.

My requirement is to check only 1st QALF from E1EDK02 segment and based on that if it is 001 then PP otherwise TT