Question

I'm trying to format decimal's to round to the nearest hundredth with a temp-table declaration similar to this.

DEFINE TEMP-TABLE foo
FIELD random-decimal AS DECIMAL FORMAT "->>>,>>>,>>>.99".

The end result is displayed on a report through which I'm using the following to output:

EXPORT STREAM sStream DELIMITER ',' foo.

This does not seem to work as I'm intending it to. I'm still receiving values like this: 0.000073.

Does anyone have any insight to what I'm doing wrong? I was unable to find anything for this specific case anyone online.

Was it helpful?

Solution

FORMAT has no impact on storage. It is only a "hint" for default display and input purposes.

What you want is the "decimals" field attribute:

DEFINE TEMP-TABLE foo
FIELD random-decimal AS DECIMAL decimals 2 FORMAT "->>>,>>>,>>>.99".

create foo.
random-decimal = 1.12345.

display random-decimal format ">.9999".
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top