Zeros Left

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
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

L. Duarte

I would treat this as a string and substring it.

result = '000' : field1[1,2] : '.' : field1[3,3]

Kim.


Kim Duke
DsWebMon - Monitor DataStage over the web
www.Duke-Consulting.com
jseclen
Participant
Posts: 133
Joined: Wed Mar 05, 2003 4:19 pm
Location: Lima - Peru. Sudamerica
Contact:

Post by jseclen »

Hi L.Duarte,

You can make a routine with this code, you must to define arguments

YourString = the string to format
"MD3Z" = The number of decimals (3 is the number, if you want another value, change it)
"9'0'R" = this is output format (9 is the long of the output string, 0 is the fill value, R is the side of the original string)

Ans = Fmt(Oconv(YourString, "MD3Z"), "9'0'R")

INPUT OUTPUT
01500 ->> 00001.500
00990 ->> 00000.990
01000 ->> 00001.000


Miguel Seclen
Lima - Peru
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

An alternative for the FMT function is to use a background.
FMT(number, "R%9") lays down a background of nine zeroes then superimposes the value of number, right justified, over that background. I believe this is marginally more efficient (in terms of machine cycles) than using a fill character.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518

This post was made purely in the interest of exploring alternatives. The solutions already posted are perfectly OK.
Post Reply