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 🙂

To report this post you need to login first.

20 Comments

You must be Logged on to comment or reply to a post.

    1. Frank Krick

      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.

      (0) 
  1. 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.

    (0) 

Leave a Reply