cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal number formatting

Former Member
0 Kudos

Hi All,

This is regarding the decimal number formatting.

1. I have an input but irrespective of the number of decimal digits, I always need three numbers after the decimal point. Eg. If the input if 12.1, I need 12.100

2. If only the integer part is present in the number, I need to have three zeros (000) after the decimal point. Eg. if I have 123, I need to have 123.000

3. if there are only two digits after the decimal point, e.g 12.22, I need to have 12.220

Can this be achieved using "formatNumber" function from XI?

Thank you

Accepted Solutions (0)

Answers (2)

Answers (2)

Jitendra_Jeswan
Contributor
0 Kudos

Solution :

Please use ".000" in the format Number Function of the Arithmatic.do not fill anything in the Decimal seperator

Source (float type) ---> format number (.000) ---> target (float type)

Hope this Helps.

Regards.

Jeet.

Former Member
0 Kudos

He has to fill decimal separator. If he doesn't than it will use server local settings.

/wg

Former Member
0 Kudos

Thank you Jeet Jeswani. It worked for me

thanks once again!!!

But I just added a 0.000 and did not put anything in the decimal separator field.

Edited by: Vincent Samuel on Mar 4, 2008 6:50 PM

Former Member
0 Kudos

Hello Jeet,

We are having problem with the formatNumber function.

As mentioned by you we have used 0.0 in the Number Format paramter and nothing the Decimal Separator parameter.

We have deployed our mappings in 6 different XI servers and no where we encountered any problem.

But in customer landscape we are getting ',' (comma) as decimal separator in the output. We have checked the server regional settings it is using USA as location and the number format shows '.' (dot) as decimal separator. But in XI when the mapping runs it puts ',' as decimal separator.

The PIISUSER, PIAPPLUSER and PISUPER users all have ',' (comma) as decimal separator. But even in the 6 servers where the mapping worked as expected, in all those servers also its same configuration for these users.

Which other setting should we check or modify? We cannot modify our code in customer environment.

Regards,

Vandana

Former Member
0 Kudos

Hi,

You could achive with standard API FormatNumber in arithmatic category of Mapping.

here you could select the format that you are expecting as output as ####.### etc

source >FormatNumber->target

refer

format-number function

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638]

Thanks

Swarup

Edited by: Swarup Sawant on Mar 4, 2008 12:37 PM

Former Member
0 Kudos

it is not working. I had a input value as 3061.95 and I get a output as 03061#95 and its not correct. I need 3061.950.

Former Member
0 Kudos

ok the multiply the source value with 1.000 you will get the required output.

you have source--->Multiply (1.000) --->target

Thanks

swarup

Former Member
0 Kudos

please use it:

#.###

/wg

Former Member
0 Kudos

nope!!!!

Former Member
0 Kudos

and that 0.000?

it works. I have checked it on my system.

/wg

Former Member
0 Kudos

try .000

Former Member
0 Kudos

no...

One question: In the "FormatNumber" function, what shall I put the first parameter as?

thx

Former Member
0 Kudos

Hi,

In number format you are puting it 0.000. And . as a separator put a dot ( . ).

/wg

Former Member
0 Kudos

Hi,

Even multiplying is also not working for it????

Can you tell me what output that you are getting .

or try for UDF testUDF with below code

Source field --> testUDF ---> target

Cache parameter == value

Source field --> A

return(String.valueOf(Float.parseFloat(A)*1.000));

Thanks

swarup

Former Member
0 Kudos

The target field is of type float

Value in the source field is 3061.95

FormatNumber is as below:

"Number Format" field has 00000.00

"Decimal Separator" field has 0.000

Output in target field is 03061095

I need 3061.950!!!!

GabrielSagaya
Active Contributor
0 Kudos

Hi

You can opt Simple UDF

import java.text.*;

function format(String a, Container container)

{

NumberFormat formatter = new DecimalFormat(".###");

String s = formatter.format(a);

return s;

}

Former Member
0 Kudos

Please use that:

"Number Format" field has 0.000

"Decimal Separator" field has .

IT WILL WORK

/wg

Former Member
0 Kudos

Dear Gabriel and Swarup,

Why are you giving code for UDF when there is the standard function?

/wg

Former Member
0 Kudos

Vincent,

I just tried the [format : ".000" / sepa.:""] settings and it works as you've requested :

12.1 -> 12.100

12 -> 12.000

12.22 -> 12.220

3061.95 -> 3061.950

Chris