Getting datastage to add a decimal point

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
HSBCdev
Premium Member
Premium Member
Posts: 141
Joined: Tue Mar 16, 2004 8:22 am
Location: HSBC - UK and India
Contact:

Getting datastage to add a decimal point

Post 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?
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DataStageCnu
Participant
Posts: 37
Joined: Sun Aug 01, 2004 1:18 am

Re: Getting datastage to add a decimal point

Post by DataStageCnu »

Hi,

Use FMT routine....

Example:

FMT( incomingField,3)

Hope this function will help you out

Srini
BB
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
HSBCdev
Premium Member
Premium Member
Posts: 141
Joined: Tue Mar 16, 2004 8:22 am
Location: HSBC - UK and India
Contact:

Post 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.
Post Reply