Number Formatting Issue using OCONV()

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
devaraj4u
Participant
Posts: 32
Joined: Mon Nov 11, 2002 12:32 am
Location: Schaumburg,Chicago

Number Formatting Issue using OCONV()

Post 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.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply