Download Blaze Trial
Follow FICO
LinkedIn   Twitter   Youtube
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Close To access this section, please choose the Community Neighborhood in which you have the most interest.

» Business Rules Management
» Collections & Recovery
» Fraud Management
» Risk Management
» Scoring
Reply
Contributor
ssah
Posts: 15
Registered: ‎03-13-2012
0
Accepted Solution

How to initialize a BigDecimal field

Hi,

 

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'.

 

 

 

Kindly advise.

 

Thanks

Shubham

Credit Risk Analyst
PayPal, Inc.
Valued Contributor
Posts: 114
Registered: ‎10-06-2008
0

Re: How to initialize a BigDecimal field

the error is telling you the solution.

 

transactionAmount = 100.00 as a BigDecimal.

 

does this give you an error?

Contributor
ssah
Posts: 15
Registered: ‎03-13-2012
0

Re: How to initialize a BigDecimal field

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. 

 

Code

print("transactionAmount":transactionAmount).

 

Output

transactionAmount:bigdecimal#1

 

 

 

I am guessing that because BigDecimal is a class, I may need a different type of declaration and assignmet.

 

Thanks

Shubham

Credit Risk Analyst
PayPal, Inc.
DM-Forums Moderator
Posts: 472
Registered: ‎10-02-2008
0

Re: How to initialize a BigDecimal field

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.

 

Regards,

Jostein

Contributor
ssah
Posts: 15
Registered: ‎03-13-2012
0

Re: How to initialize a BigDecimal field

Hi Jostein,

 

Thanks for the explanation. The method works!

 

Thanks,

Shubham

Credit Risk Analyst
PayPal, Inc.