cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Special Char in Result

senthil_kumar44
Participant
0 Kudos

Hi,

I have an issue in Query (Xacute or any query) results. How to replace special char like  (",/,\) in results by escape char like " should be \" and \ like \\
.

Is it possible to do with XSL? I tried by using xsl but it is showing "unable to create inline transformation error".

Can you please help to solve this issue?

Thanks,

Senthil

Accepted Solutions (0)

Answers (1)

Answers (1)

swaroop_anasane
Active Contributor
0 Kudos

Hi Senthil,

Let me know what are you trying to achieve by doing this replacement. Would be able to suggest something on that.

Thanks,

Swaroop

senthil_kumar44
Participant
0 Kudos

Hi Swaroop,

The issue is in query results if some special char like " or \ is present (like - This is \ test $",), then in JSON format result, it is showing error and we are not able to handle this output in SAP UI5. So we want to replace all these special char (",\,/) as \",\\ and \/. So i created XSL for it but while applied in inline transformation, it is showed error as "Unable to create Inline transformation".

Thanks,

Senthil

saivellanki
Active Contributor
0 Kudos

Hi Senthil,

You can acheive it through BLS.

Create two local variables like below

When you are printing the results into XML Output Document, use stringreplace() expression.

Hope this Helps!!

Regards,

Sai Vellanki.

swaroop_anasane
Active Contributor
0 Kudos

Hi Senthil,

Generally, JSON would not create any problem if the string is quoted within "". My json has data as

Plant :"Nitro\"/ Glycirides"

and the same is plotted on the UI5 ch art without any error. Please find the attachment for the same.

The problem could be from BLS or query side. Check if the result set is generated properly or not. Also, validate your JSON.

Thanks,

Swaroop

Former Member
0 Kudos

Swaroop,

Exactly as you said, the text in your json, Plant :"Nitro\"/ Glycirides" already has the double quote character escaped. Due to this, the json response is valid and hence the chart gets plot for you.

This is exactly what Sai has suggested in his reply.

If the response in the json contains a double or single quote as a part of json key OR value, then it considers it as end of string and hence becomes invalid.

@Senthil, if you are using a query which is returning bad json, then as suggested by Sai, execute the query inside a transaction's action block, then repeat over the response row wise and escape all the values where your string contains a double quote using stringreplace() function.

At the end of your iteration, the response xml will contain escaped double quotes. This output of transaction when retrieved using xacute query as text/json will give you the desired output.

Regards,

Rutika Bodas