Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

sap formcalc minimum trailing decimal

Avatar

Level 1

Hi,

I have a formcalc field, total_gross_weight, use to sum up all the gross_weight field input by user. Its requirement are:


Case: total_gross_weight decimal place must be able change dynamically according to user input in the gross_weight field.

eg: gross_weight_1 + gross_weight_2 + ... = total_gross_weight

1.001 + 2.000 + 3.000 = 6.001 (3decimal) - success

1.0012 + 2.000 + 3.000 = 6.0012 (4decimal) - success

1.000 + 2.000 + 3.000 = 6. - FAIL. (it should be 6.000) 

I can make it change dynamically but i cannot retain the minimum trailing zero.

how can i show the minimum trailing zero, and still can be dynamic?

Seeking for advice.

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 1

Issue solve by using At(str, ".") to detect the decimal places of the text field.

Thank you

View solution in original post

5 Replies

Avatar

Level 10

Hi,

use a pattern like num{zz9.999888}.

The 8 is for optional decimal places and the 9 for always present decimal places.

So an input of 1.0 will be formatted to 1.000 and an input of 1.00001 to 1.00001.

Avatar

Level 1

Hi Radzmar,

I have tried tried to test with just num{zz9.888}, whereby if input 1.0, output should be 1.0

but it does not work. is there a bug in the pattern? it still comes up as whole number, 1.

Please advise. Thank you

.forum1.PNG

Avatar

Level 10

No, you misunderstood me.

The decimal places with an 8 in the pattern will only appear if the value is not 0.

So with num{z99.888} the decimal places will only appear when they are not 0.

When you use the pattern num{zz9.998} the first and second decimal place will be always shown, even with 0 values and only the third is optional. When you enter 2, or 2.0, or 2.00 or 2.000 it will be formatted into 2.00 but when you enter 2.123 it's formatted into 2.123

Avatar

Level 1

oh i see. but my issue is that i need to display the trailing zero when the value is zero, dynamically.

eg:

input -> output

1.00    ->     1.00

1.000     -> 1.000

1.0000     -> 1.0000

the trailing zero must appear according to the number of trailing zero user input. it must be dynamic.

seeking for advice. thank you.

Avatar

Correct answer by
Level 1

Issue solve by using At(str, ".") to detect the decimal places of the text field.

Thank you