Skip to Content
Author's profile photo Former Member

Special character’s handling in PI/XI simplest ever.

We normally come across this very common issue where special characters are received from ECC and passes through PI successfully and at receiving system it fails as the receiver does not accept special characters.

Especially when we are dealing with Bank scenarios, the protocols at Bank’s end are very strict and the payments are rejected very frequently.

The major problem is that these characters do not get detected as they are not visible with naked eyes or in payload.

If you try opening payload in notepad then you will be able to figure out.

Normally when we try to deal with special characters we focus on the characters which are not acceptable, but while using this technique we normally miss some or the other character and the problem persists.

So to deal with special character problems, I have used a method which is fool proof and can anytime be used very easily and in very simple way anytime and in any version of PI/XI.

In this method we will be concentrating on the allowed characters list rather than not allowed ones.

It is a simple reusable java code which can be used to write and UDF and can be used for any input fields which need special character handling.

In this code we will match the input field character by character with the allowed list and if the character of input field matches the one from the allowed list, add them to the string buffer and return the list from the buffer in the end.

Capture.PNG

 

This is the best and simplest ever practice to deal with special characters in PI 🙂

Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Very Helpful Document

      Author's profile photo Tejas Jani
      Tejas Jani

      This is an excellent document which explains the most commonly faced issue resolved in the simplest manner. Helped a lot. Thank you!

      Author's profile photo Former Member
      Former Member

      helpful thanks

      Author's profile photo Former Member
      Former Member

      Thanks for sharing this!

      Author's profile photo Former Member
      Former Member

      Very Helpful document.

      Author's profile photo Ramesh Palle
      Ramesh Palle

      Helpful Document. Thanks...!!!

      Author's profile photo Former Member
      Former Member

      nice document....

      Author's profile photo Astha Makhija
      Astha Makhija

      Very helpful document. Thanks.

      Author's profile photo Former Member
      Former Member

      Good One.

      Author's profile photo Raghu Vamseedhar Reddy KadipiReddy
      Raghu Vamseedhar Reddy KadipiReddy

      This is my opinion.

      Using this UDF, there will be data loss in middle-ware (only alpha numeric characters are allowed). I will not recommend this solution.

      Author's profile photo Former Member
      Former Member

      I can do shorter. [44 Character]:

      return a.replaceAll("[^a-zA-Z0-9-'+/.]", "")

      Author's profile photo Former Member
      Former Member

      simple yet powerful  and useful. innovatively used. Regex has always been like this 🙂

      Author's profile photo Former Member
      Former Member

      Cheerss ...good document !!!

      Author's profile photo Former Member
      Former Member

      But, wouldn't this cause data loss?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      No It won't cause any data loss, try it.

      Author's profile photo Former Member
      Former Member

      Yes it does, it is equivalent to this much shorter version:

      return a.replaceAll("[^a-zA-Z0-9-'+/.]", "")

      And it replaces everything that is not in the regexp class [a-zA-Z0-9-'+/.] with an empty character.

      So this 0123abcABC$%^&* becomes this 0123abcABC


      Whether or not that is okay depends on the functional requirements. But it most certainly removes data from the input.

      Author's profile photo Former Member
      Former Member

      I agree with Frank, the code removes special characters which may or may not be necessary (depending on functional requirements). I haven't tried it yet though.

      Author's profile photo Amit Saini
      Amit Saini

      Good Document ...

      Author's profile photo Former Member
      Former Member

      Good thought, however In my openion it will cause data loss.

      We need to use this UDF depends on functional requirement.

      Author's profile photo Binod Mondal
      Binod Mondal

      Thanks for the document and your effort. Just wanted to mention that as per my understanding boolean variable that is declared is not at all required/used in the UDF.