Fomat problem

make

Member
Hi there,
i have a decimal like this :

58842,2349

and i want to have this :
58842,235

how can i do this , is there a round function or can i use the format phrase ?

Greets
 

laa

Member
ROUND ( expression , precision )

expression

A decimal expression.

precision

A non-negative integer expression whose value is the number of places you want in the decimal result of the ROUND function.

EXAMPLE

This procedure increases all credit-limit values by 10 percent, rounding those values to the nearest $100.

r-round.p

FOR EACH customer:
DISPLAY cust-num name credit-limit.
credit-limit = ROUND( (credit-limit * 1.1) / 100 ,0) * 100.
PAUSE.
DISPLAY credit-limit.
END.
 

jongpau

Member
Hi Make,

If your field or variable ALWAYS needs to have the 3 decimals, you can use the DECIMALS option when you declare the variable or field. Try the next code to see what I mean:
Code:
DEF VAR dDecimal  AS DEC NO-UNDO.
DEF VAR dDecimal3 AS DEC NO-UNDO DECIMALS 3.
DEF VAR dDecimal4 AS DEC NO-UNDO DECIMALS 4.

ASSIGN dDecimal  = 58842.234912454
       dDecimal3 = dDecimal
       dDecimal4 = dDecimal.

MESSAGE dDecimal  SKIP
        dDecimal3 SKIP
        dDecimal4
        VIEW-AS ALERT-BOX.
HTH
 
Top