cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for succeeding character replace

Former Member
0 Kudos

Hi All,

I am facing an issue that we get a one of the field "Amount", where we get '-' value succeeding.

eg: Exactdata: if Amount = -999, in SAP we get that as 999-, which is incorrect and gets fail at the PI level, which is not able to accept by the DB side at the other end.

So, can we replace this value with the exact once at the PI level using graphical mapping or using UDF we can achieve it..If so, help me..

eg: exact data: -44, but data in SAP occurs as 44-

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hello Ram,

Please see the below screenshots..

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Ram,

               Please can you try this


public static String minusSign(String s)

  {

       if(s!="" || s!=null)

       {

            int len=s.length();

            if(s.charAt(len-1)=='-')

            {

                 s="-"+s.substring(0,len-1);

            }

      }

  return s;

}

output

---------

String input=44-

Output=-44

String input=6777-

Output=-6777

String input=-67

Output=-67

String input=67

Output=67

Harish
Active Contributor
0 Kudos

Hi Ram,

Yes you can replace the value in graphical mapping

e.g.

Value --> If ends with (Text function) - --> Then replace - with blank and concate with - in the start

Else --> Pass the source value

Please let me know if it is difficult for you to visualise the function.

regards,

Harish