Jump to content

Help! Division does not work in Variable Expression


dogfuel

Recommended Posts

I'm stumped... addition, subtraction and multiplication work for me, but division does not.

 

iReport Version is 4.1.1, Report Language is groovy

variables $V{DirectHrs1_1} and $V{TotalHrs1_1} are java.math.BigDecimal and simply sum fields for a group.

When defining a third variable, also java.math.BigDecimal, the expressions:

$V{DirectHrs1_1} +  $V{TotalHrs1_1 does work

$V{DirectHrs1_1} -  $V{TotalHrs1_1 does work

$V{DirectHrs1_1} *  $V{TotalHrs1_1 does work

$V{DirectHrs1_1} /  $V{TotalHrs1_1) does NOT work!

 

With division, the report compiles, but does not fill with error:

 Compiling to file... C:UsersjbairdDocumentsTimesheetDetail.jasper Compilation running time: 332!


 Filling report...  Locale: English (United States)  Time zone: Default Error filling print... Error evaluating expression : 
    Source text : $V{DirectHrs1_1} /  $V{TotalHrs1_1}
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : $V{DirectHrs1_1} /  $V{TotalHrs1_1} 
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203) 
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589) 
    at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:141) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:291) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:133) 
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:903) 
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:813) 
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58) 
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417) 
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247) 
    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:878) 
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) 
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) 
Caused by: java.lang.ArithmeticException: Division undefined 
    at java.math.BigDecimal.divide(Unknown Source) 
    at org.codehaus.groovy.runtime.typehandling.BigDecimalMath.divideImpl(BigDecimalMath.java:66) 
    at org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv$NumberNumber.invoke(NumberNumberDiv.java:320) 
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40) 
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124) 
    at TimesheetSummary_1336422548811_243902.evaluate(calculator_TimesheetSummary_1336422548811_243902:255) 
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190) 
    ... 13 more 
Print not filled. Try to use an EmptyDataSource...

Link to comment
Share on other sites

  • 1 year later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...