Skip to Content
0

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

Apr 12, 2017 at 12:14 AM

121

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Evgeniy Kolmakov Apr 12, 2017 at 11:44 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Ravi M Apr 13, 2017 at 07:35 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Apr 13, 2017 at 08:09 AM
0

Hi RaviTeja!

Please attach your source XML file and XSLT file.

Regards, Evgeniy.

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeniy,

Have attached similar source files but it contains only 4-5 fields. The actual one is having around 240 fileds.

Similar xml file:

http://abc.com/md/Test">

Similar xsd file:

http://www.w3.org/2001/XMLSchema" xmlns=" http://abc.com/md/Test" targetNamespace=" http://abc.com/md/Test">

Regards,

RaviTeja M

0

Hi RaviTeja!

I can't see any attached files, only partially copy-pasted fragments.

Regards, Evgeniy.

0

Hi Evgeniy,

Please find the attached similar source content.

Thanks,

RaviTeja Mcalculatetax.txtconsider-it-as-sourcefile.txt

0

Thanks much Evgeniy,

we have modified the xsl as the below and got the actual outuput:

xls Code:

http://www.w3.org/1999/XSL/Transform" version="1.0">

Output:

AQQQ55555511111111111111111111122222222223333333334444444444DG3SSSSSS

Regards,

RaviTeja M

0

Hi RaviTeja!

I guess I've got the problem's root: forum engine replaces escape sequenses with its actual values.

I've attached xslt source I provided above. Please pay your attention: "<" and ">" symbols around CDATA element should be replaced with escape sequenses.

Regards, Evgeniy.

wrapwithcdata.txt

0