cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI 7.30 - Special Characters in the Payload

former_member191528
Participant
0 Kudos

Hello All,

Our message mapping is failing due the special character like % sign in the payload.

What is the recommended best practice in SAP PI for handling special characters in payload. ?

The sample XML column is shown below.

<NameofJob>ABC XYZ (10%)</NameofJob>

Thanks,

Kiran

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

A % is not a special sign and need not treated specially.

Could you post the error message which you receive, when the mapping is failing?

former_member191528
Participant
0 Kudos

Hello Stephen and Raghu,

The following is another example of the payload

  <MaterialDescription>ROUND BOX 2-3/8" X 10&#3;</MaterialDescription>

The following is the error

Thanks,

Kiran

<SAP:Stack>Runtime exception occurred during application mapping com/sap/xi/tf/_WorkOrderStatusUpdatePublish2Updat~; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Fatal Error: com.sap.engine.lib.xml.parser.ParserException: XMLParser : #3 not allowed in Character~</SAP:Stack>

stefan_grube
Active Contributor
0 Kudos

So actually you have ASCII 3 in the source message, a non-printable character.

Try to fix the issue on sender side, they should clean the data before sending.

RaghuVamseedhar
Active Contributor
0 Kudos

Kiran,

It is highly recommended to request the sender system, to fix the code and generate well-formed XML. I agree with

As last option, follow the solution Not well-formed XML - & issue.

former_member191528
Participant
0 Kudos

Hello Stefan & Raghu,

We have the following process. The user enters the following text.

The ECC process then calls a PI service via consumer proxy and the following payload is sent to PI

<MaterialDescription>ROUND ALUM DIGN POST 2-3/8" X 10&#3;</MaterialDescription>

Can you please let me know where this transformation is happening  ?

Thanks,

Kiran

RaghuVamseedhar
Active Contributor
0 Kudos

Kiran,

It seems ABAP proxy (SAP) is not following W3C standard.

' should be represented as &apos; if it is present in data. Ask ABAP team to fix it.

If they can't, implement Java mapping mentioned in the blog 'Not well-formed XML - & issue'. Use this replace logic,

replaceAll("&#3;", "&apos;"); OR replaceAll("&#3;", "'"); // replace with &apos; or '

FYI.

Link.

There are 5 predefined entity references in XML:

&lt;<less than
&gt;>greater than
&amp;&ampersand
&apos;'apostrophe
&quot;"quotation mark
stefan_grube
Active Contributor
0 Kudos

Is your ECC not a unicode system? In that case your connection settings are not correct. Check it.

I wonder which character was entered by the user. An apostrophe should not cause any issues. Maybe it is an accent like ´ or ` ?

By the way: Within an XML element, an apostrophe need not be escaped. Only two characters must be escaped: < and &

former_member191528
Participant
0 Kudos

Hi Stefan & Raghu,

Our SAP system is not Unicode enabled but SAP PI is Unicode enabled. I was looking into the SM59 connection to our XI box from ECC and I found the following info.

I also verified that the special character is an apostrophe and not an accent.

With the current set up is Java Class in Operation Mapping the only way to handle this issue ?

Thanks,

Kiran

RaghuVamseedhar
Active Contributor
0 Kudos

Kiran,

My opinion, implement Java Mapping. Let's see, what Stefan thinks.

replaceAll("&#3;", "'");

stefan_grube
Active Contributor
0 Kudos

I have no idea how to solve it. An apostrophe should not cause trouble.

I cannot imagine how an apostrophe becomes ascii value 3. That makes no sense.

As the sender is an ABAP proxy, I think the issue is in the ABAP code.

It is hard to giva an advice without looking into the system.

Of course a Java mapping could replace the value, on the other side: when apostrophe becomes a wrong value, I assume that many other characters become wrong values as well.

RaghuVamseedhar
Active Contributor
0 Kudos

Kiran,

FYI. HTML-code of ' is &#39; and End of Text is &#3;

The ABAP report program, where user is entering data is not storing data properly to SAP database.

Unicode.

former_member191528
Participant
0 Kudos

Thanks Raghu & Stefan !! I really appreciate you all taking time to assist with the issue.

Answers (1)

Answers (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Kiran,

Download the payload and save it with .txt extension. Open the payload with foxe or notepad++. Determine if the XML is not well-formed. Link.

Please post the screen of payload opening with notepad++ or foxe. We can guide you further.