Packed Decimal conversion

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
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Packed Decimal conversion

Post by rhettbutlernc »

I need to convert the numbers usually padded with zeros to a packed decimal number (eg:00000123456789).

I am using a routine to do this but all the leading zeros are being stripped.

Code: Select all

InputNbr = Oconv(InputNbr, "MCN")

Ans=iconv(InputNbr, "MP")
Guess this has to do with the Options. I would appreciate if someone could help me...

Thanks.
-Davis
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's the Oconv that's stripping zeroes.

To retain them, wrap in a Fmt function.

Code: Select all

InputNbr = Fmt(Oconv(InputNbr, "MCN"), "R%14")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Post by rhettbutlernc »

The zeros were not being stripped. It was just that the CFF stage not displaying them... I used UltraEdit to view the Hexadecimal equivalent of the leading zeros.

Thanks :)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can do a trim(yourval, '0', 'L')
Post Reply