cancel
Showing results for 
Search instead for 
Did you mean: 

Special Character Handling (< >) in the payload content in PI 7.1

Former Member
0 Kudos

Hello All,

Scenario:

SOAP -> PI -> RFC (calling BAPI_DOCUMENT_CREATE2)

The soap message contains some special characters in the description fields ex: "DESC <SDH>"

when I am map the request to this RFC - I place the description field inside CDATA Structure and the RFC Request will look like as follows:


  <?xml version="1.0" encoding="UTF-8" ?> 
  <ns0:BAPI_DOCUMENT_CREATE2 xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
  <DOCUMENTDATA>
  <DOCUMENTTYPE>DRW</DOCUMENTTYPE> 
  <DOCUMENTNUMBER>SDH_DOC_005</DOCUMENTNUMBER> 
  <DOCUMENTVERSION>00</DOCUMENTVERSION> 
  <DOCUMENTPART>000</DOCUMENTPART> 
  <STATUSEXTERN>IA</STATUSEXTERN> 
  <VALIDFROMDATE /> 
  </DOCUMENTDATA>
  <DOCUMENTDESCRIPTIONS>
  <item>
  <LANGUAGE>DE</LANGUAGE> 
  <DESCRIPTION><![CDATA[DESC <SDH> 
  
  
  EN 
  DESC <SDH> 
  
  
  
]]>

This request is successfully executed by RFC - but when I go to R/3 and look for the result - in the document description it looks as follow:

DESC & ltSDH& gt
Note: I purposefully inserted the space after & - because this editor does 
not allow me to write together!

Does anybody have solution to overcome this effect in SAP R/3- do I need any more mapping?

@ Stefan: As per your suggesstion - I am starting a new thread for this issue:

And below is your comment for the same issue on the other thread!

Of course it does. What do you expect when you use CDATA?

Open a new thread as this is some totally different as the original post.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Stefan,

when I use CDATA - I expect that the XML parser will treat the content as string and won't parse them at all and it is as such passed to RFC Adapter and I expect that the result in R/3 should be "DESC <SDH>" - but it is not!

Best Regards,

Satish.

Former Member
0 Kudos

Hello Stefan,

As you suggested, I tried without using CDATA in my request and it look like as follows:


 <?xml version="1.0" encoding="UTF-8" ?> 
 <ns0:BAPI_DOCUMENT_CREATE2 xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
 <DOCUMENTDATA>
  <DOCUMENTTYPE>DRW</DOCUMENTTYPE> 
  <DOCUMENTNUMBER>SDH_DOC_006</DOCUMENTNUMBER> 
  <DOCUMENTVERSION>00</DOCUMENTVERSION> 
  <DOCUMENTPART>000</DOCUMENTPART> 
  <STATUSEXTERN>IA</STATUSEXTERN> 
  <VALIDFROMDATE /> 
  </DOCUMENTDATA>
 <DOCUMENTDESCRIPTIONS>
 <item>
  <LANGUAGE>DE</LANGUAGE> 
  <DESCRIPTION>DESC <SDH></DESCRIPTION> 
  </item>
 <item>
  <LANGUAGE>EN</LANGUAGE> 
  <DESCRIPTION>DESC <SDH></DESCRIPTION> 
  </item>
  </DOCUMENTDESCRIPTIONS>
  </ns0:BAPI_DOCUMENT_CREATE2>

but the result is same as earlier - when I look into R/3 instead of the symbol (< >) - it displays still & lt; and & gt; in the description field

Best Regards,

Satish.

stefan_grube
Active Contributor
0 Kudos

> when I use CDATA - I expect that the XML parser will treat the content as string and won't parse them at all and it is as such passed to RFC Adapter and I expect that the result in R/3 should be "DESC <SDH>" - but it is not!

Of course not, as the original data are &gt and &lt instead of < >

Otherwise you could not send the data with SOAP.

Former Member
0 Kudos

is there any workaround suggested for this problem?

stefan_grube
Active Contributor
0 Kudos

I have just tested it:

when you put <tag> &gt ; &lt ; &amp ; </tag> in payload, the RFC adapter forwards the values <>&

Check your source SOAP document or your XI message with a plain text editor (Notepad) to see how the values look like.

Former Member
0 Kudos

My source SOAP message contains &lt ; &gt ; - I am using the JAVA mapping to convert them to the right symbols (< >) and place them in the CDATA structure u2013 without CADTA the XML wonu2019t be a valid one.

My earlier thread contains the XI Message and I did not find anything special even if I copy them to Notepad u2013 it is same as above.

stefan_grube
Active Contributor
0 Kudos

> My source SOAP message contains &lt ; &gt ; - I am using the JAVA mapping to convert them to the right symbols (< >) and place them in the CDATA structure u2013 without CADTA the XML wonu2019t be a valid one.

Instead of replacing & gt and & lt, try to use the same values of SOAP adapter unchanged.

> My earlier thread contains the XI Message and I did not find anything special even if I copy them to Notepad u2013 it is same as above.

Do mean mean you copy with ^c ^v? That of course will not change anything.

Store the payload as local file and open with Notepad.

Former Member
0 Kudos

I tried all the options you mentioned u2013 but I did not see any further changes!

stefan_grube
Active Contributor
0 Kudos

> My source SOAP message contains &lt ; &gt ; - I am using the JAVA mapping to convert them to the right symbols (< >) and place them in the CDATA structure u2013 without CADTA the XML wonu2019t be a valid one.

I cannot imagine that the receiver RFC adapter will change <> symbols in a CDATA section to escape sequences.

In fact the RFC adapter replaces escape sequences back to the symbols. I have used this behaviour in a scenario and it worked for me in any PI release.

So I have to assume that your JAVA mapping is not working correctly or your inbound payload from SOAP adapter is totally different.

When you have an escape sequence in message payload, you will not see it in SXMB_MONI, and not in Internet explorer.

Maybe you show your Java mapping code to see, if it is working like it should.

Former Member
0 Kudos

Inbound payload looks like as follows: [I have cut and pasted the below line from SXMB_MONI]


<attribute name="DocumentDescription" system="MP" value="DESC &lt;SDH&gt;" /> 
Note: as you mentioned - SXMB_MONI is not displaying the symbols just escape sequence: & lt; and & gt;

>you will not see it in SXMB_MONI, and not in Internet explorer.

I saved my XML Payload locally and opened in Internet Explorer and also in XML SPY [inbuilt Browser] - both the browser showed me & lt; and & gt; - they did not show me the symbols.

Below is my UDF: just replaces the occurens [& lt; with < and & gt; with > and wrap the string in the CDATA structure]


		String currentData = new String(var1);
		
		currentData =currentData
                                      .replaceAll("& lt;", "<")
                                       .replaceAll("& gt;", ">");

		currentData = "<![CDATA[" + currentData + ""; // I tried even commenting this line.
		return currentData;
]]>

stefan_grube
Active Contributor
0 Kudos

> >you will not see it in SXMB_MONI, and not in Internet explorer.

> I saved my XML Payload locally and opened in Internet Explorer and also in XML SPY [inbuilt Browser] - both the browser showed me & lt; and & gt; - they did not show me the symbols.

Things are not always as they seem.

0 Kudos

Is there any idea on this post? I'm having the same issue now, also tried all possibilities mentioned here.

Seems RFC receiver adapter doesn't parse "<" ">" at all.

Thanks in advance.

Former Member
0 Kudos

We raised an OSS call to SAP and waiting for a fruitful solutions - at present we do not have any better solutions.

-Satish.

stefan_grube
Active Contributor
0 Kudos

> Seems RFC receiver adapter doesn't parse "<" ">" at all.

Do following:

- dowload the payload from SXMB_MONI to file system

- open the file with a hexeditor (there are enough freeware hex editors*)

check if the < is "<", "& gt ;" or "& amp ; gt ;" (without spaces)

sxmb_moni, internet explorer and other editors do not display the escape sequences correctly

stefan_grube
Active Contributor
0 Kudos

What happens, when you do not use CDATA? Just map DESCRIPTION as is?

That should work.