Link to home
Start Free TrialLog in
Avatar of esther_6694
esther_6694

asked on

Suppress leading zero for a decimal number

Can I ask how to suppress leading zero for a decimal number?
e.g.
2.35 -> 2.35
1.70 -> 1.7
Avatar of dougvarga
dougvarga
Flag of United States of America image

SAP Support Note 1212998 - Covers this.  But you have to download a UFL.
Here's my adaptation -

Put this in the DECIMALS Formula

Set the ROUNDING to the Max positions you want to show.
Example if you want 2 decimal places max set Rounding to 0.01

-Doug


//Number Formatting Formula to Eliminate Trailing Zeros.
//Put this in the DECIMALS Formula
//Set the ROUNDING to the Max positions you want to show.
//Example if you want 2 decimal places max set Rounding to 0.01
 
//SAP Support Note 1212998 - Covers this.  But you have to download a UFL.
//Here's my adaptation -
 
local StringVar array a := Split (ToText(CurrentFieldValue),".");
local stringvar s := Trim(a[2]);
local numbervar result;
local numbervar x;
 
for x := len(s) to 1 step -1 do
(
    if s[x]<> "0" then (
        result:=x;
        exit for;
    );
);
result

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dougvarga
dougvarga
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of esther_6694
esther_6694

ASKER

Thanks, it works.