03-20-2012 08:39 AM
Suppose transactionAmount is a defined as a BigDecimal in the JAVA OM, how to initialize it and give it a default value.
Following code gives the error as shown below.
transactionAmount = 100.00;
Error: Explicit cast required to assign a 'real' to a 'BigDecimal' use 'as a BigDecimal'.
Solved! Go to Solution.
03-21-2012 09:27 AM
Thanks for your reply.
I have tried that as well. It complies fine but when I print the value out, the value is not passed correctly.
I am guessing that because BigDecimal is a class, I may need a different type of declaration and assignmet.
03-22-2012 03:31 PM
What you see is the default representation of an object instance in Blaze Advisor. A BigDecimal instance is (at least in your case) not treated as a primitive, and is therefore represented by the instance "id" in Blaze.
If you would like to print the value represented by the BigDecimal instance, try one of the following: ("theValue" contains a reference to a BigDecimal instance)
For monetary values:
asMoney is some money initially theValue as a money;
print("value: " asMoney);
For decimal values (and you are not concerned about the possible loss of precision):
asReal is some real initially theValue as a real;
print("value: " asReal);
For integer values (still not concerned about precision etc..):
asInteger is some integer initially theValue as an integer;
print("value: " asInteger);
Please note that you can do the cast inside the print(), it is separated here for readability. Also please note that I didn't test these lines of code right now, but they should work.