Skip to Content

SAP PI/PO Mapping Issue for XML field

Hi Guys,
I need your help with following mapping assistance.
String populated in an XML field from response has to be split to a customized structure.
It's something like this:
Response is as below: XML Fieldname: <GetExchangeRatesResult>

Whole string in XML field: <MNBExchangeRates><Day date="2018-10-30"><Rate unit="1" curr="EUR">329,82000</Rate><Rate unit="1" curr="USD">296,81000</Rate></Day></MNBExchangeRates>

<GetExchangeRatesResult>
<MNBExchangeRates><Day date="2018-10-30"><Rate unit="1" curr="EUR">329,82000</Rate><Rate unit="1" curr="USD">296,81000</Rate></Day></MNBExchangeRates>
</GetExchangeRatesResult>

The target structure should look like this:
<MT_ExchangeRatesResponse>
<DATE>2018-10-30</DATE>
<ISOCD>EUR</ISOCD>

<FRUNIT>1</FRUNIT>

<TOUNIT>1</TOUNIT>

<EXCHNGE_RATE>329,82000</EXCHNGE_RATE>

<ISOCD>USD</ISOCD>

<FRUNIT>1</FRUNIT>

<TOUNIT>1</TOUNIT>

<EXCHNGE_RATE>296,81000</EXCHNGE_RATE>

</MT_ExchangeRatesResponse>

Mapping object:

How to achieve the above requirement with mapping in SAP PI. I tried to look through few blogs, couldn't find an appropriate resolution. Kindly help on this

mm.jpg (47.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Nov 08, 2019 at 10:17 PM

    Hi Vaibhav,

    You can you use the below XSL mapping as a 1st step in your OM to produce the XML data and then use that in your graphical mapping in the 2nd step mapping.

    XSL mapping -

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:output method="xml" indent="yes"/>
    
    <xsl:template match="node() | @*">
    
    <xsl:copy>
    
    <xsl:value-of select="." disable-output-escaping="yes" />
    
    </xsl:copy>
    
    </xsl:template>
    
    </xsl:stylesheet>
    
    

    This will produce the below output -

    The target output from XSL and the actual target structure can be used in a 2nd step graphical mapping.

    Here is the OM -

    Thanks

    Sugata


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.