Page 1 of 1

Getting datastage to add a decimal point

Posted: Tue Nov 30, 2004 5:35 am
by HSBCdev
My Basic problem is that I can't work out how to get datastage to interpred 80000 as 80.000 (I wan't to be able to do it just by defining the field correctly).



I'm trying to run a job to convert an EBCDIC file into ASCII.
This file has a header, many details, and a trailer record.

I've started of with a CFF stage where I defined it as 1 record format which has 1 character field which is the length of the whole record.

This goes to a transformer where I send the file to different files based on the 1st character of the record (which tells you if its a header, detail or trailer).

So, the detail records end up being written into a seq. file as one long field.

When I view the data in this file the amount field that I am interested in contains 000000000000080000 - which represents 80.000 (i.e. its total length is 18 and the last 3 digits are after the decimal point).

I then have defined an output from that file which has the correct format for the detail record (i.e. each field is defined - rather than 1 long field), but I can't get datastage to interpret 000000000000080000 as 80.000.

I've tried defining it as decimal with length 15 scale 3 but it seems to add on an extra .000 - giving me 80000.000 instead of 80.000 .

What am I doing wrong here?

Is there an easier way for me to approach this?

Posted: Tue Nov 30, 2004 7:53 am
by kcbland
Unless you perform some derivation other than a straight mapping DS will not attempt to scale data. Try adding zero ( link.column + 0) to your value to see if DS will be nice and adjust your data.

However, your situation is one of an implied decimal. You will have to divide by 1000 to get your answer. The scale column only indicates how many decimal places, not implied.

Re: Getting datastage to add a decimal point

Posted: Tue Nov 30, 2004 8:03 am
by DataStageCnu
Hi,

Use FMT routine....

Example:

FMT( incomingField,3)

Hope this function will help you out

Srini
BB

Posted: Tue Nov 30, 2004 9:11 am
by kcbland
Actually, you can use OCONV with the MDxy token. The y will shift decimals and the x will set the decimal place. So, MD33 will shift the decimal 3 positions, then round to 3 places. Likewise, MD24 will shift 4 places and then round to 2.

Posted: Tue Nov 30, 2004 10:42 am
by HSBCdev
Thanks all,

I've put in a transformer and just divided the amount fields by 1000. I'd thought that I should be able to insert my decimal point just by getting the column definition right - and so avoid having a transformer.

I'd misunderstood what the scale on the column definition was supposed to do.

Thanks for explaining it.