Negative Values in Decimal

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
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Negative Values in Decimal

Post by paranoid »

Hi,

We are having an input file where the negative decimal value is of the following format:

Eg: 123.00 -

We need to convert this to -123.00

Is there any simple function that we can achieve this?

Thanks

Sue :D
ramsubbiah
Participant
Posts: 40
Joined: Tue Nov 11, 2008 5:49 am

Re: Negative Values in Decimal

Post by ramsubbiah »

i am not sure if any separate function for achiving your result but try the below
use the substring function
column[(len(column)-1),1]:column[1,(len(column)-1)]

Thanks,
Ram.s
Knowledge is Fair,execution is matter!
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

You can use a transform or routine , Arg1 will be the input decimal column.. Assuming Server Jobs : )

Code: Select all

Ans = If Oconv(Arg1,"MC/N") Matches "...-..." 
Then Fmt(-1*Trim(Arg1,"-","A"),"R2") Else Arg1
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Or you can even use a simple derivation like

If Count(Column,'-') > 0 Then '-' : Field(Column,'-',1) Else Column
Arun
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Or you can even use a simple derivation like

If Count(Column,'-') > 0 Then '-' : Field(Column,'-',1) Else Column
Arun
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Read about the Iconv/Oconv "MD" (masked decimal) conversions, which can handle trailing signs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Very good suggestion ray. This would be very useful
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Something like

Code: Select all

 Iconv(InLink.TheDecimal, "MD2-") 
should do it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Thanks everyone.. I tried all the logics and finally used Ray's logic.

Have a nice day!!

Sue :D
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

ray.wurlod wrote:Something like

Code: Select all

 Iconv(InLink.TheDecimal, "MD2-") 
should do it. ...
This is great. I never thought it would handle a trailing sign, though I use "MD" a lot. Thanks Ray.
Arun
Post Reply