implied decimals

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
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

implied decimals

Post by vinnz »

In my project we are using flat files to interface with external systems.
In the interface layout specification, there are certain columns with an implied decimal&sign which need to be mapped to a decimal(10,2) field in DB2 using an ODBC stage.
I am not sure how to handle implied decimal fields so I was thinking of just dividing by 100 and then pasing the result but then I tried using the 'DataTypePic9V99' transform and it worked.
But now I need to do the reverse i.e. possibly export some fields which are of type DECIMAL(10,2) to a sequential file in an implied decimal format and am unsure how to do it and of what length it can potentially be (10 or 12) including the sign and implies decimal.

thanks in advance,
paul

Env: DS 7 on AIX
source: flat files, SQL Server, DB2
target: flat files, DB2
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
Decimal(10,2) means 8 digits number and 2 digits after the decimal point so if you do a * 100 you get decimal(10,0) at most.
In any case you can use the decimal(12,2) if needed to comply with both situations.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ejazsalim
Premium Member
Premium Member
Posts: 51
Joined: Wed Apr 09, 2003 6:42 am
Location: VA, USA

Post by ejazsalim »

Why dont you just multiply by 100 and write out to a CHAR field I assume what you want to do is


Code: Select all

Input = 12345.67       Output = 1234567
Look at the FMT function

Code: Select all

Fmt (string, format)
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Post by vinnz »

Thank you for all your replies.
One more question is how does the sign come into play here? Will I need an extra character?

I am tempted to just re-define the layout for the flat file to day that the field a_amount is of type char(12) with one extra char for the sign and one for the decimal point but that will be a waste if it is not needed.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Iconv(string, "MD2") will generate the "implied decimal place" you require.
Read about MD conversions in on-line help or in the BASIC manual.

Remember, also, that there is only one data type in a text file: text. So you can use substringing and other techniques where appropriate.
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