One Star

conversion issue from string to bigdecimal?

hi guys,
my input is like tis..
Process_Compliance
-----------------------
N-Apl
3.5
4.3
3.5
N-Apl
4.2
N-Apl

my script in tmap is---->
row2.Process_Compliance.equals("N-Apl")
?BigDecimal.valueOf(0):
new BigDecimal(row2.Process_Compliance);
need output as
Process_Compliance
-----------------------
0
3.5
4.3
3.5
0
4.2
0
when i run my job with above script,i am getting following bug..

xception in component tMap_1
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at

pls let me know any one Smiley Happy
thanking u
9 REPLIES
One Star

Re: conversion issue from string to bigdecimal?

Hi
You'd better set the type of this column "String" and type expression in tMap as follow.
row2.Process_Compliance.equals("N-Apl")?"0":row2.Process_Compliance

Regards,
Pedro
One Star

Re: conversion issue from string to bigdecimal?

hi pedro,
thanks for given quick reply...,i understood wht u mean.....but my target table field as bigdecimal always....

if that is the case,how we can convert from string to bigdecimal?

pls let me know....
One Star

Re: conversion issue from string to bigdecimal?

Hi
Here is another workaround.
Use tReplace component to replace "N-Apl" with "0".
Then use tMap to convert String to BigDecimal.
new BigDecimal(row.ColumnName)                    //row.ColumnName should be String.

Regards,
Pedro
One Star

Re: conversion issue from string to bigdecimal?

hi pedro,
i am getting...
Process_Compliance
-----------------------
0.00
0.00
0.00
0.00
0.00
0.00
after i used the baove code,any how...i am getting input as ...
Process_Compliance(Input Column)
-----------------------
N-Apl
3.5
4.3
3.5
N-Avl
4.2
NA
sorry,the above logic is not helpfull,
why can't we decode in tmap & convert from string to bigdecimal????????,can we get that way......any thing...

thanks
One Star

Re: conversion issue from string to bigdecimal?

Hi
Here are the screenshots.
Regards,
Pedro
One Star

Re: conversion issue from string to bigdecimal?

hi pedro,
my input is different...
tis is my input,
Process_Compliance(Input Column)
-----------------------
N-Apl
3.5
4.3
3.5
N-Avl
4.2
NA
how we can use tReplace tis is the case?
One Star

Re: conversion issue from string to bigdecimal?

Hi
You can check "Advanced mode" of tReplace.
"^N.*"

Regards,
Pedro
One Star

Re: conversion issue from string to bigdecimal?

it's works fine... Smiley Happy

Thank u Pedro.... (Y)
One Star

Re: conversion issue from string to bigdecimal?

hi guys,
i am getting following issue with tmap......after i done the above steps...
Exception in component tMap_1
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)

pls let me know any one wht was the cause?

thank u