rasinc Posted February 2, 2020 Share Posted February 2, 2020 I have an inventory-type report grouped by PartId. There is a total of the QtyToFulfill column for each group.I want to subtract the total of the QtyToFulfill (BigDecimal) from the QtyOnHand (Double) field.I've tried$F{QTYONHAND}.subtract($V{qtyToFulfill_1})and $F{QTYONHAND}.subtract($V{qtyToFulfill_1}.DoubleValue())I am sure it has to do with the datatype but I don't know the correct syntax.Can someone give me a hand figuring this out?TIA rasinc. Link to comment Share on other sites More sharing options...
luked Posted February 3, 2020 Share Posted February 3, 2020 Try changing your $V{qtyToFulfill_1} field to BigDecimal.$F{QTYONHAND}.subtract(BigDecimal.valueOf($V{qtyToFulfill_1})) Link to comment Share on other sites More sharing options...
rasinc Posted February 3, 2020 Author Share Posted February 3, 2020 Thanks for the reply. I added the formula to the Variable Expression and double-checked that I had set everything to BigDecimal and now I get the errorThe method valueOf(long, int) in the type BigDecimal is not applicable for the arguments (BigDecimal)The express is$F{QTYONHAND}.subtract(BigDecimal.valueOf($V{qtyToFulfill_1}))and put the variable in the group footer. QTYONHAND is showing as a double in the field list in the expression editor. Any ideas what else I can try? Link to comment Share on other sites More sharing options...
luked Posted February 3, 2020 Share Posted February 3, 2020 In your variable have the Value Class Name set to java.math.BigDecimal and try putting the same infront of your $F{QTYONHAND}.BigDecimal.valueOf($F{QTYONHAND}).subtract(BigDecimal.valueOf($V{qtyToFulfill_1})).Keep your field class for $F{QTYONHAND} as java.math.BigDecimal and your variable class for $V{qtyToFulfill_1} as java.lang.Double.Only change the class in your calculation variable. Hopefully that helps you out Link to comment Share on other sites More sharing options...
swood_1 Posted February 4, 2020 Share Posted February 4, 2020 Looks like luked is on it! Link to comment Share on other sites More sharing options...
bigalex Posted February 4, 2020 Share Posted February 4, 2020 Try $F{QTYONHAND}.floatValue() - $V{qtyToFulfill_1}.floatValue() Link to comment Share on other sites More sharing options...
rasinc Posted February 4, 2020 Author Share Posted February 4, 2020 Thank you for the help and direction luked. You helped me understand the math and syntax a little better.Final answer is:BigDecimal.valueOf($F{QTYONHAND}).subtract($V{qtyToFulfill_1}) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now