avatar image
Former Member

Mandatory filed starts with Special Character

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    May 08, 2014 at 08:50 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2014 at 08:54 AM

    Thank you Eng Swee for speedy reply

    Add comment
    10|10000 characters needed characters exceeded

    • 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

      regex.png (17.2 kB)
  • May 08, 2014 at 08:55 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content