Skip to Content
avatar image
Former Member

SAP PI - UDF

Dear Experts,

   How to write java code (udf) for below requirement?

For example, in source file, Brand = 'BK' and customer code = '5123' (starts with 5 ) then print Value "X" else value "Y".

Thank you.

Deva

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 06, 2013 at 02:18 AM

    Hi,

    In Message Mapping you can handle with standar functions.

    Otherwise you can check this javacode

    String sResult = null;if(Brand.equalS("BK") && CustomerCode.startsWith("5"))   result = "X";else   result = "Y";return result;

    Regards

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Can you clarify your logic

      For example:

      If, Brand = 'BK' and customer code = '5123' (starts with 5 ) then print Value "3299971" else value "Y then ...etc

      The sintax is incorrect because always return else condition.

      for example return "3299971"; return "3299973";return "3299978";

      if (Brand.equalsIgnoreCase ("BK") && CustNo.startsWith("5")){return "3299970";";}else if (Brand.equalsIgnoreCase ("DQ") && CustNo.startsWith("5")){  return "3299972";


  • Mar 06, 2013 at 07:04 AM

    Dear Deva,

    Though your query has been answered but for your requirement you could always use standard node functions.

    You can achieve your reqrmnt using EqualS, AND and IfThenElse function and its always preferred to use node over UDF.

    Regards

    Anand

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Anand Shankar

      Dear Anand,

          I understood your query and your graphical mapping and perferctly correct.

      In my requirement, i have to follow 10 times same mapping as you shown me in once.

      So, there is no space for me .So i wrote UDF.

      Deva