Page 1 of 2

Decimal to integer

Posted: Thu Mar 09, 2006 3:43 pm
by somu_june
Hi,

Iam using an stagevariabe as integer .ex total (variable)

Total(integer) = Total(integer)+Reclinenumber(decimal). I want this Reclinenumber to convert to integer.How to convert decimal to integer can I take it asinteger function to convert decimal to string. Please help me


Thanks
Somaraju

Posted: Thu Mar 09, 2006 4:21 pm
by ray.wurlod
AsInteger may generate warnings, because the potential exists for your decimal number to be too large to fit in an integer. If you can be 100% certain that this will never be the case, equip a message handler for this message in this job to demote the warning to informational.

Posted: Thu Mar 09, 2006 5:03 pm
by somu_june
Hi Ray,


Sorry Iam not able to understand. What is this equip a message. Is there any solution for this . please help me.


Thanks
Somaraju

Posted: Thu Mar 09, 2006 5:24 pm
by ray.wurlod
No. DataStage will always generate the warning. Because you need the warning. If you want to you can create a message handler to demote the warning to an informational message. Search is your friend.

Posted: Thu Mar 09, 2006 5:30 pm
by rasi
Somu

The easiest way is to convert your decimal to integer use AsInteger

Total(integer) = Total(integer)+AsInteger(Reclinenumber(decimal)).

Posted: Fri Mar 24, 2006 10:14 am
by vinaymanchinila
How can we convert an integer to string, we have source column as 2 , and we need it to be padded with 0s for lenght of 3 i.e. 002.


Thanks,

Posted: Fri Mar 24, 2006 10:26 am
by vcannadevula
vinaymanchinila wrote:How can we convert an integer to string, we have source column as 2 , and we need it to be padded with 0s for lenght of 3 i.e. 002.


Thanks,

You can use the padstring() function

Posted: Fri Mar 24, 2006 11:27 am
by vinaymanchinila
Thanks for the inputs, when I used PadString() its padding at the end so its making a 1 to 10 , I was expecting 01 !

Posted: Sat Mar 25, 2006 5:40 am
by kumar_s
Use MantissaFromDecimal or need to pad the string of 0s to the left of the existing number manually after calculating the length (digint) of the existing number.

Posted: Mon Mar 27, 2006 9:08 am
by vinaymanchinila
Right now using FMT(SrcColumn, "2'0'R") , wil post it if I come across any better ideas.

Posted: Mon Mar 27, 2006 9:00 pm
by kumar_s
Are you using transformer or BasicTransformer?

Posted: Fri Mar 31, 2006 9:05 am
by vinaymanchinila
The basic transformer.

Thanks,

Posted: Fri Mar 31, 2006 11:26 am
by vsurap
Right( ("000":SrcColumn) , 3 )

Posted: Wed May 03, 2006 1:46 pm
by vinaymanchinila
Hi,
FMT(SrcColumn, "4'0'R") was working fine but when it hits a -ve number it pads like this 00-12 instead of -012 .
Any ideas on how to correct this !

Thanks,

Posted: Wed May 03, 2006 8:23 pm
by ray.wurlod

Code: Select all

(If (SrcColumn < 0) Then "-" Else "") : Fmt(Abs(SrcColumn), "R%" : (4 - (SrcColumn < 0))) 
or

Code: Select all

If SrcColumn < 0 Then "-" : Fmt(Abs(SrcColumn), "R%3") Else Fmt(SrcColumn, "R%4")
"R%4" is another way to represent "4'0'R" but fewer keystrokes.