cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory filed starts with Special Character

Former Member
0 Kudos

Hello All

Request your help in mapping. I am using SAP PI 7.3

I have source field "ID" with 1.1 occurrence. if ID starts with "?" or any other special character then the entire message should fail in SAP PI 7.3

Example: ID == ?_Example,  then entire message should fail. else the value in the ID field should be passed

can we achieve it through graphical mapping? if not can somebody share the UDF for the same.

Regards

James

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi James

You can throw an exception in a UDF. Example below of the source code.


if (input.startsWith("?")){

  throw new RuntimeException("Enter Exception Text");

} else {

  return input;

}

Rgds

Eng Swee

Answers (2)

Answers (2)

AntonioSanz
Active Participant
0 Kudos

Hello,

perhaps you can try to use a "if whitout else" clause in message mapping and "startswith" and "not", and use it for mapping the first node of the result message.

So if it starts with "?" the mapping will return an empty message and in your integration scenario it will launch an exception and will not follow.

Regards.

Former Member
0 Kudos

Thank you Eng Swee for speedy reply

engswee
Active Contributor
0 Kudos

Hi James

Just to add, if you need to handle other special characters as well, you can use the following for your IF condition. It uses Regex to check if the first character is non-alphanumeric


if (input.substring(0,1).matches("\\W")){

You can check what \W with the regex reference below.

Rgds

Eng Swee