Skip to Content

CDATA tag with field fixed lengths values not the parameter/field names in SAP PI

Hi Team,

we have a requirement to send the data in CDATA tag with the values only as filed fixed lengths values not the parameter names or filednames. In the soap:Body/Document we have around 120 parameters.

They need only values field fixed lengths not the parameter names in the CDATA tag.

I think ...concating the 120 fields by using the graphical mapping is not the best approach...

we are using HTTP adapter in our scenario

Input xml :

</soap:Header> <soap:Body> <rcm:Document><VendorNumber>1201798795</VendorNumber><SystemName>TIBCO</SystemName>.................. </rcm:Document> </soap:Body>

Expected output:

</soap:Header> <soap:Body> <rcm:Document> <Generic_CData><![CDATA[1201798795 TIBCO 2017-04-102017 ORDERS 8092905 0001 ]]></Generic_CData> </rcm:Document> </soap:Body>

Thanks,

RaviTeja

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Apr 12, 2017 at 11:44 AM

    Hi RaviTeja!

    You could use XSLT transformation for your requirement:

    Input XML

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Document xmlns:ns0="http://tempuri.org">
        <VendorNumber>1201798795</VendorNumber>
        <SystemName>TIBCO</SystemName>
        <Element1>Value_Element1</Element1>
        <Element2>Value_Element2</Element2>
    </ns0:Document>

    Transformation

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:ns0="http://tempuri.org" version="1.0">
        <xsl:template match="/">
            <MT_Output>
                <rcm:Document xmlns:rcm="http://custom_uri">
                    <Generic_CData>
                        <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
                        <xsl:for-each select="/ns0:Document/node()">
                            <xsl:value-of select="normalize-space(.)"/>
                        </xsl:for-each>
                        <xsl:text disable-output-escaping="yes">]]></xsl:text>
                    </Generic_CData>
                </rcm:Document>
            </MT_Output>
        </xsl:template>
    </xsl:stylesheet>

    Result

    <?xml version="1.0" encoding="utf-8"?>
    <MT_Output xmlns:ns0="http://tempuri.org">
        <rcm:Document xmlns:rcm="http://custom_uri">
            <Generic_CData><![CDATA[1201798795TIBCOValue_Element1Value_Element2]]></Generic_CData>
        </rcm:Document>
    </MT_Output>

    Just modify given XSL transformation according to your source message structure.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 13, 2017 at 07:35 AM

    Thanks Evgeniy,

    I tried by modifying the xsl code..There is an exception message during mapping execution-Unable to display tree view; Error when parsing an XML document (The element type "Generic_CData" must be terminated by the matching end-tag "</Generic_CData>".)

    Input xml-

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

    http://abc.com/xi/pos/CalculateTax">

    <CalculateTax_Output>

    <NumberofRecords>1</NumberofRecords>

    <CompressionIndicator>2</CompressionIndicator>

    <CompressionCharacter1>3</CompressionCharacter1> <CompressionCharacter2>4</CompressionCharacter2>

    xsl Modified:

    http://www.w3.org/1999/XSL/Transform" xmlns:ns0=" http://abc.com/xi/pos/CalculateTax" version="1.0"> http://schemas.xmlsoap.org/soap/envelope/">

    <ns1:Body>

    http://www.abc.com/2.0/rcm">

    http://abc.com/xi/pos/CalculateTax">

    <Generic_CData>

    <xsl:text disable-output-escaping="yes">

    <![CDATA[</xsl:text> <xsl:for-each select="/CalculateTax_Output/node()"> <xsl:value-of select="normalize-space(.)"/> </xsl:for-each> <xsl:text disable-output-escaping="yes">]]></xsl:text>

    </Generic_CData>

    </ns0:CalculateTax_Req>

    </ns2:Document>

    </ns1:Body>

    </ns1:Envelope>

    </xsl:template>

    </xsl:stylesheet>

    Exception during the exceution of mapping with xsl code ected output is:Unable to display tree view; Error when parsing an XML document (The element type "Generic_CData" must be terminated by the matching end-tag "</Generic_CData>".)

    parameters-in-source-and-target.jpgoperationmapping.jpgTarget Structure:

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

    http://schemas.xmlsoap.org/soap/envelope/">

    <ns1:Body>

    http://www.abc.com/2.0/rcm">

    http://abc.com/xi/pos/CalculateTax">

    <CalculateTax_Output>

    <NumberofRecordsIn>1</NumberofRecordsIn><CompressionIndicator>2</CompressionIndicator><CompressionCharacter1>3</CompressionCharacter1><CompressionCharacter2>4</CompressionCharacter2></CalculateTax_Output></ns0:CalculateTax_Req></ns2:Document></ns1:Body></ns1:Envelope>

    The content under the node-<CalculateTax_Output> should be converted as

    <Generic_CData><![CDATA[1234_Element1Value_Element2]]></Generic_CData>error-message-during-mapping-execution.jpg
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 13, 2017 at 08:09 AM

    Hi RaviTeja!

    Please attach your source XML file and XSLT file.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded