Leading Sign and Zero Filled Decimal Amount Fields

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
antman
Participant
Posts: 3
Joined: Thu May 01, 2008 7:08 am
Location: Cincinnati OH

Leading Sign and Zero Filled Decimal Amount Fields

Post by antman »

Good Afternoon,
I need to build a sequntial file for a vendor. They need the amount fields in the format +000100.01 or -000100.01. The data is coming from a DB2 table and looks like -100.01 or 100.01. I've tryed messing with the FMT and OCONV functions, but I can't seem to hit the nail on the head. I was also thinking of breaking the output data into seperate fields and doing some sort of position by position read of the input field, but I have to believe there's an easier way. I'm kind of frustrated since this seems to be a fairly simple thing to accomplish. I'm new to Datastage and am still learning on the job, so any help is appreciated.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

FMT should work fine for your zero fill needs, it's just that you'll need to 'manually' prefix the sign on the amount. Creating a separate field for the sign is one simple way to accomplish this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
antman
Participant
Posts: 3
Joined: Thu May 01, 2008 7:08 am
Location: Cincinnati OH

Post by antman »

Mr. Hulett,

Thank you for the info. Much appreciated

Carl Antkowiak
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

np. If you have any more questions on this topic, be sure to come back and ask.
-craig

"You can never have too many knives" -- Logan Nine Fingers
antman
Participant
Posts: 3
Joined: Thu May 01, 2008 7:08 am
Location: Cincinnati OH

Post by antman »

With your advice I did the seperate sign field. I check the first byte of the input amount field for the sign and populate the output field. I then used the following code in my transform to handle the leading zeros:

If substrings(DSLink4.OPEN_AMT,1,1) = '-' then
FMT(DSLink4.OPEN_AMT*-1,"16'0'R2") else
FMT(DSLink4.OPEN_AMT,"16'0'R2")

It seems to work just fine. Thanks again.

Carl .. :D
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Great! Please mark the thread as Resolved using the big button at the top of the screen.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply