cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert trailing minus sign into the leading minus sign

Former Member
0 Kudos

Hi

Can any plz tell me How to convert trailing minus sign into the leading minus sign? I mean in PI the amount filed shows like 150.00- i want to convert that into -150.00.

Thanks

Govinda

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

its always better to check if the field contains the minus sign first before doing the manipulation;

additional if condition will help;

if(a.indexOf("-") > 0)
{
return ("-" + a.substring(0,a.indexOf("-")) );
}
else
{return a;}

Former Member
0 Kudos

Hi

Thanks a lot.

Thanks

Govinda.

Former Member
0 Kudos

Hi Shabarish,

The code works but what if the input is something like [   10.000-] i.e. with some spaces before 10.000- and the output as per your code comes as [-     10.000]. How do we tackle such cases if there is inconsistency in data i.e. some values come as [    10.000-] i.e. spaces before the number and some values as [12.000-].

The output of this will come as

[-    10.000]

[-12.000]

How to make it as

[-10.000]

[-12.000]

Regards,

Shaibayan

Answers (3)

Answers (3)

Former Member
0 Kudos

Govinda:

Hope you can assist me with the same issue you describe.

I also need to have the minus sign in front of amount ex: -200.00.

How did you do this?

I want to do this in a transformation rule.

Thanks for your time

Denny

Former Member
0 Kudos

Try using standard functions in graphical mapping

replaceString --> replace tailing - by constant (nothing)

concatenate constant - with the resultant string

former_member181985
Active Contributor
0 Kudos

Use the following UDF,

amount Field(Source)>UDF>Target Field

UDF Code:

return ("-" + a.substring(0,a.indexOf("-")) );

- Gujjeti.