Page 1 of 1

Number Formatting Issue using OCONV()

Posted: Tue Oct 28, 2003 9:58 pm
by devaraj4u
Dear All,

I have one field(Interest_Rate) in my ardent which is a decimal value.But when i am writing into a file i require that number as S9(10)V9(8) format (COBOL format ie Sign in Front)...

For example if THE Interest_Rate is say '4.5678' then it should be formatted as '000000000456780000' .

Please help me how to use the OCONV() or FMT() funtion for the same.

I Tried using

IF (Interest_Rate < 0) Then
"-" : OCONV(ABS(Interest_Rate) * 100000000, "MR0(%18)")
Else
" " : OCONV(ABS(Interest_Rate) * 100000000, "MR0(%18)")

But the above mentioned thing is not working for me...


Thanks & Regards,
K.S.Rajan.

Posted: Tue Oct 28, 2003 11:03 pm
by vmcburney
Try this:
fmt(input.amount*100000000, "R0%18")
The multiplier removes all the decimal points and the right justify with % padding puts the number into the right hand side of 18 zeros.

Posted: Wed Oct 29, 2003 4:27 am
by ray.wurlod
You still need an If construct to handle the leading sign, since this needs to be prepended AFTER the formatting. For example:

Code: Select all

If input.amount < 0 Then "-" : Fmt(Abs(input.amount)*100000000,"R0%18") Else Fmt(input.amount*100000000,"R0%18")