Page 1 of 1

implied decimals

Posted: Wed Apr 21, 2004 9:09 am
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

Posted: Wed Apr 21, 2004 9:19 am
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,

Posted: Wed Apr 21, 2004 9:42 am
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)

Posted: Wed Apr 21, 2004 12:46 pm
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.

Posted: Wed Apr 21, 2004 4:48 pm
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.