Page 1 of 1

Leading Sign and Zero Filled Decimal Amount Fields

Posted: Thu Sep 04, 2008 10:42 am
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.

Posted: Thu Sep 04, 2008 11:09 am
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.

Posted: Thu Sep 04, 2008 11:32 am
by antman
Mr. Hulett,

Thank you for the info. Much appreciated

Carl Antkowiak

Posted: Thu Sep 04, 2008 11:50 am
by chulett
np. If you have any more questions on this topic, be sure to come back and ask.

Posted: Thu Sep 04, 2008 11:58 am
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

Posted: Thu Sep 04, 2008 12:07 pm
by chulett
Great! Please mark the thread as Resolved using the big button at the top of the screen.