Jump to content
We've recently updated our Privacy Statement, available here ×

problem with condition in variable expression


nicoheber

Recommended Posts

Hey guys,

i have a problem with conditions in variables.

I want to show the availabilities for some routers in a report. For this i created a master and a subreport. In the subreport i select the data for a router. When there are data, theres no problem. But when there are no data it only shows null for my calculations.

 I have two variables. The first is totaldowntime which sums all downtimes. The second calculates the availability with the formula: 100-$V{totaldowntime}/2592000*100. This works when there are data.

But i want something like

( $V{totaldowntime}=null ? 100 : 100-$V{totaldowntime}/2592000*100 ) from the user defined expression ( <condition> ? exp1 : exp2 ). But this dont work, i get the error:

Errors compiling D:\Documents and Settings\heber\My Documents\ireports\Standortverfügbarkeit_subreport1.jasper! Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@10093bc

 

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

calculator_Standortverfügbarkeit_subreport1_1304507380743_695713: 179: 

"(java.lang.Long) variable_Gesamtdowntime.getValue().toLong()" is a method call expression, but it should be a variable expression at line: 179 column: 103. File: calculator_Standortverfügbarkeit_subreport1_1304507380743_695713 @ line 179, column 103.

1 error

 

    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:101)

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:188)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:131)

    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:515)

    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)

    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

calculator_Standortverfügbarkeit_subreport1_1304507380743_695713: 179: 

"(java.lang.Long) variable_Gesamtdowntime.getValue().toLong()" is a method call expression, but it should be a variable expression at line: 179 column: 103. File: calculator_Standortverfügbarkeit_subreport1_1304507380743_695713 @ line 179, column 103.

1 error

 

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)

    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:829)

    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)

    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)

    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)

    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:97)

    ... 6 more

 Can someone help me there?

 

nico

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

i made a mistake changing the language. Now i really changed the language to Java and i get an other error.

 

The left-hand side of an assignment muss be a variable: ($V{totaldowntime}=null ? 100 : 100-$V{totaldowntime}/2592000*100 )

 

this means for me that left of the : has to be variable like $V{availability}=100. But this dont work too.

then i get the message: Syntax error on token "=", != expected : ($V{totaldowntime}=null ? $V{availability}=100 : $V{availability}=100-$V{totaldowntime}/2592000*100 )

when i change this like in the message. i get again the error that The left-hand side of an assignment muss be a variable.

So where is my real mistake now?

 

edit

i changed

$V{totaldowntime}=nullto $V{totaldowntime}==null 

so i dont get the message. but as result i get null too. so this dont really work :(



Post Edited by nicoheber at 05/06/2011 09:17
Link to comment
Share on other sites

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