cancel
Showing results for 
Search instead for 
Did you mean: 

Query on XSLT mapping

Former Member
0 Kudos

Hi All,

I am working on IDoc to File scenario using xslt mapping.

There is a requirement to map the corresponding partner ids based on partner functions say

If for each segment E1ADRM1 if PARTNER_Q =WE then map the corresponding partner id to a tag .

Below is the xslt code I am using but it is taking only the first partner id not the corresponding one

                    <xsl:for-each select="$E1EDL20/E1ADRM1[PARTNER_ID='WE']">
                    
<ShipToLocationCode>
                    <xsl:value-of select="$E1EDL20/E1ADRM1/PARTNER_ID"/>
                    </ShipToLocationCode>
                    </xsl:for-each>

Please suggest me how to take the corresponding partner.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Swmya,

Im sorry, but i dont understand your requeriment. You are only taking the partner PARTNER_ID='WE'' then is normal that your <xsl:value-of select="$E1EDL20/E1ADRM1/PARTNER_ID"/> select always the partner with the id WE.

Could you share an example?

Regards.

Former Member
0 Kudos

Hi,

I have posted the incorrect code by mistake. My code is:

<xsl:for-each select="$E1EDL20/E1ADRM1[PARTNER_Q='WE']">

                     <ShipToLocationCode>
                    <xsl:value-of select="$E1EDL20/E1ADRM1/PARTNER_ID"/>
                    </ShipToLocationCode>
                    </xsl:for-each>

The above code is not taking the corresponding partner ID which has Partner=WE, instaead it is taking whatever is the first Partner_ID in the IDoc.

Please suggest a code to take the corresponding one.

Thanks

iaki_vila
Active Contributor
0 Kudos

HI Sowmya,

With this source XML:

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

<E1EDL20>

    <E1ADRM1>

        <PARTNER_Q>WE</PARTNER_Q>

        <PARTNER_ID>ONE</PARTNER_ID>

    </E1ADRM1>

    <E1ADRM1>

    <PARTNER_Q>HE</PARTNER_Q>

    <PARTNER_ID>TWO</PARTNER_ID>

    </E1ADRM1>

    <E1ADRM1>

        <PARTNER_Q>WE</PARTNER_Q>

        <PARTNER_ID>THREE</PARTNER_ID>

    </E1ADRM1>

</E1EDL20>

If i use this XSL:

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

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

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">

     <root>

        <xsl:for-each select="E1EDL20/E1ADRM1">

            <xsl:if test="./PARTNER_Q='WE'">

                <ShipToLocationCode>

                    <xsl:value-of select="./PARTNER_ID"/>

                </ShipToLocationCode>

            </xsl:if>

        </xsl:for-each>

     </root>

    </xsl:template>

</xsl:stylesheet>

I get the next XML:

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

<root>

    <ShipToLocationCode>ONE</ShipToLocationCode>

    <ShipToLocationCode>THREE</ShipToLocationCode>

</root>

I hope this helps you.

Regards

Former Member
0 Kudos

Thanks a lot! It worked.

Answers (0)