cancel
Showing results for 
Search instead for 
Did you mean: 

Replace special characters inside mapping using UDF in SAP CPI

n_rvsavinashvarma
Participant
0 Kudos
4,134

Hi Everyone,

We have a requirement in SAP CPI to read each special character from the input and replace it with respective value.

Input :

<Data1>Árvíztűrő tükörfúrógépÆâÇßÐ</Data1>

Expected Output :

<Data1>Arvizturo tukorfurogepAEaCssD</Data1>

I am able to handle the same using replace function in groovy script but i want to handle the same in mapping.

Can someone please suggest.

Regards,

Avinash

Accepted Solutions (0)

Answers (4)

Answers (4)

MortenWittrock
Active Contributor

Hi Avinash

Add a custom function in your Message Mapping and reuse the code, that already works in your Groovy script.

Regards,

Morten

0 Kudos

Hi Avinash,

Try below code as a custom groovy udf in message mapping, and use it for required fields as a mapping rule.

import java.text.Normalizer
str = Normalizer.normalize(str, Normalizer.Form.NFD);
str = str.replaceAll("[^\\p{ASCII}]", "");return str;

Regards,

Srikanth Vadlamani

0 Kudos

Thanks Srikanth,

Its worked for me.

Regards,

Abdul

maik_bosch
Contributor
0 Kudos

Hi Avinah,

maybe have a look at XSLT mappings?

https://stackoverflow.com/questions/3067113/xslt-string-replace

BR Maik

n_rvsavinashvarma
Participant
0 Kudos

Hi All,

Can someone express their views on this request.

Regards,

Avi