cancel
Showing results for 
Search instead for 
Did you mean: 

CData in graphical mapping for line feed

Former Member
0 Kudos

Hello!

I have ABAP Proxy to JDBC asynchronous scenario.

SAP PI 7.4 single stack.

Elements with line feed (i.e. <BPFullName>Sample Name&#xA;</BPFullName> ) are sometimes sent from sender system.

These line feed symbols are converted to real line feeds after mapping (instead of &#xA; ).

Our JDBC receiver gives error in this case because SQL statement becomes separated into two lines:

     java.sql.SQLException: Found a quote for which there is no matching quote.


I know that this issue is solved when value is escaped by CData like this:


            <fname><![CDATA[line_1

            line_2]]></fname>


Please tell me how to wrap some element into CDATA using graphical mapping.


Best regards,

Andrey Petin

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Andrey!

Maybe I don't understand your question right but why not to just concat your field data with "![CDATA[" and "]]" in your mapping?

Regards, Evgeniy.

Former Member
0 Kudos

Hello Evgeniy!

Yes, that may help. I thought about it but there are some doubts.

If an element value is already quite long, it is automatically surrounded by CDATA and all that.

I'm not sure what will there be if I add CDATA one more time.

former_member190293
Active Contributor
0 Kudos

Hi Andrey!

Then develop reusable UDF for current and future requirements :

public String wrapWithCDATA(String srcStr, Container container) throws StreamTransformationException {

     if (srcStr == null || srcStr.trim().equals("") || srcStr.trim().startsWith("![CDATA["))

          return srcStr;

     else         

          return "![CDATA[" + srcStr.trim() + "]]";

}

Regards, Evgeniy.

Answers (2)

Answers (2)

suman_sourabh
Participant
0 Kudos

Hi Andrey,

You can concat the original value with "<![CDATA[" and "]]>" in grapical map to add the Cdata segment.

Hope this will help.

Regards,
Suman

former_member186851
Active Contributor
0 Kudos

Hello Andrey,

Instead of CDATA try the below approach.

scn.sap.com/people/jyothi.anagani/blog/2010/06/17/convert-the-input-xml-to-string-in-pi-71-using-standard-graphical-mapping

This is will return entire XML as string..

Former Member
0 Kudos

Hi!

I have complicated mapping with logic for almost every single field.

So this approach will not be helpful here. I need CDATA for some specific fields.