avatar image
Former Member

Mapping: How to map XPath nodes based on attribute values in SAP PI

Hello all,

I am new to SAP PI and have the following sender message structure as follows:

<Attribute name="VENDOR_ACCOUNT_NUMBER">
<Attribute name="VENDOR_ACCOUNT_GROUP">
<Attribute name="LEGAL_ENTITY">
<Attribute name="NAME1">
<Value>XYZ COMPANY</Value>

And the following receiver target structure


Question: I would like to do the following mappings

Item/Attribute[@name="VENDOR_ACCOUNT_NUMBER"]/Value --> CREMAS05/E1LFA1M/LIFNR

and so on.

What is the best approach to do the above mappings? Is the above doable using Graphical mapping. If not what are the other alternatives to achieve the desired target values.

Thanks and Regards,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 28, 2017 at 04:30 PM

    Hi am suggesting to use XSLT. For such a small message the graphical tool will work, too. But I could imagine that you also want to fill the E1LFB1M segment, etc. And then it will become soon very complex.

    above example would be:

    <xsl:template match="/">
    <xsl:apply-templates select="//ItemData"/>

    <xsl:template match="ItemData">
    <E1LFA1M Segment="1">
    <LIFNR><xsl:value-of select="Attribute[name='VENDOR_ACCOUNT_NUMBER']/Value"/><LIFNR>

    you see, it's very easy to write down, much easier than the graphical playground.



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you the sample XSLT, Helmut. The message I provided was only a snippet of the actual message.

      In reality, the source message has a lot of fields and everything is represented as a key/value pair, where Attribute element is the field name and Value element is the value for that field.

      This helps a lot!!!



  • Mar 23, 2017 at 11:25 PM


    You can map this structure in graphical mapping with standard functions.


    name --> mapwith default --> equals ("VENDOR_ACCOUNT_NUMBER") --> If without else--> Map value



    Add comment
    10|10000 characters needed characters exceeded

Skip to Content