Can a String be converted to BigDecimal(java.math.BigDecimal) type?
I have an input value as a string which is actually a number. I need to pass it to a JDBC adapter service which is accepting only java.math.BigDecimal type.
Are there any built-in services available out of the box to achieve this. I tried searching it in WmPublic (v7.1.2) pkg but no joy…
Can anyone please help me with this or do I have write a java code to do this?
Any suggestions or ideas is highly appreciated.
Tong_Wang
(Tong Wang)
February 21, 2014, 9:32pm
2
I think writing a few lines of Java code is the easiest way of doing this.
Hi mahesh
You will have a service in wmtransformations package which is used to convert string to big decimal, Please check for this package.
let me know if you require any help.
Regards
Sandeep
Hi Sandeep,
Can you please share the package and do the needful
I tried find it on SAG tech community and on Google but I was not able to find anywhere.
Hi Mahesh,
You can try using this service pub.math:toNumber which is un WmPublic package.
Regards,
Sireesha
Hi Sireesha,
Yes you are correct but unfortunatley this service is not present in wM 7.1.2 we are not upgraded yet.
If you have Wmtransformations pkg kindly share it to me.
Thanks,
Mahesh
I dont have that package…
But can you try this java code…
public static final void convertString(IData pipeline) throws ServiceException {
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String inString = IDataUtil.getString( pipelineCursor, “inString” );
pipelineCursor.destroy();
BigDecimal output = BigDecimal.valueOf(Long.parseLong(inString));
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
//Object output = new Object();
IDataUtil.put( pipelineCursor_1, “output”, output );
pipelineCursor_1.destroy();
}
Hope it works for you…
Thanks,
Sireesha Avala
rmg
(rmg)
February 28, 2014, 3:50pm
8
We cannot share packages here and please check the share ware section also in this forum.
http://techcommunity.softwareag.com/codesamples
HTH,
RMG
@ Sireesha Avala,
I will have a look at your code. Thanks
@ rmg,
We have many code samples here. Let me see if I can find Wmtransformations pkg. Thanks