Jump to content
Changes to the Jaspersoft community edition download ×

PROBLEM with Expression in VALUES FORM!!!


Recommended Posts

By: Anuradha - anura

PROBLEM with Expression in VALUES FORM!!!

2003-08-19 02:48

Hello..

I'm creating a report using "iReports" and i face the following problem:

 

The SUMMARY part of the ouput shud get me the

SUM of values of the FIELD NAME "ACT_LIAB1"(that is, Sum of Account liability values) only when the fieldname "PROD_SUB_TYPE" = "ACD"...This is one particular condition.

Here the field name "ACT_LIAB1" is of type

"java.lang.double"

and "PROD_SUB_TYPE" is of type "java.lang.String"

 

How do i go about this..?

 

I approached in the following manner and 'am getting errors which 'am not

able to resolve:

 

My Approach:

--------------------

My filename is "custnew.xml"

Suppose, if create a new VARIABLE "sum_varSumCustgfcid" in the "VALUES FORM" and give the following INITIAL VALUE EXPRESSION in it(where the Calculation type is "SYSTEM" , variable type is "java.lang.double", and i maintain a GROUP with

a specific GROUP NAME: "Custgfcid"):

My expression is :

 

(($F{PROD_SUB_TYPE}.toString().equals("ACD")) ? (new java.lang.Double(

$V{sum_varSumCustgfcid}.doubleValue() += $F{ACT_LIAB1}.doubleValue())) : (new java.lang.Double($V{sum_varSumCustgfcid}

.doubleValue())))

 

 

 

Errors Displayed after compiling in iReports:

--------------------------------------------------

 

C:jdk1.3.1_01binjava.exe

Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser IReportCompiler -c

-pdf -jdriveroracle.jdbc.driver.OracleDriver -juserBLine -jpasswdindia

-jurljdbc:oracle:thin:@163.37.3.175:1666:bline -query "select * from

r_trb_dp" "C:iReport-0.1.0iReport-0.1.0bincustnew.xml"

 

File: C:iReport-0.1.0iReport-0.1.0bincustnew.xml

 

Compiling to file... C:iReport-0.1.0iReport-0.1.0bincustnew.jasper

 

Warning : Element bottom reaches outside band area : y=11 height=23

band-height=20

 

dori.jasper.engine.JRException: Errors were encountered when compiling

report expressions class file:

C:iReport-0.1.0iReport-0.1.0bincustnew.java:222: unexpected type

required: variable

found : value

value = (java.lang.Double)

(((((java.lang.String)field_PROD_SUB_TYPE.getValue()).toString().equals

("ACD")) ? (new java.lang.Double

(((java.lang.Double)variable_sum_varSumCustgfcid.getValue()).doubleValue()

+= ((java.lang.Double)field_ACT_LIAB1.getValue()).doubleValue())) : (new

java.lang.Double(((java.lang.Double)variable_sum_varSumCustgfcid.getValue

()).doubleValue()))));

^

C:iReport-0.1.0iReport-0.1.0bincustnew.java:470: unexpected type

required: variable

found : value

value = (java.lang.Double)

(((((java.lang.String)field_PROD_SUB_TYPE.getOldValue()).toString().equals

("ACD")) ? (new java.lang.Double

(((java.lang.Double)variable_sum_varSumCustgfcid.getOldValue()).doubleValue

() += ((java.lang.Double)field_ACT_LIAB1.getOldValue()).doubleValue())) :

(new java.lang.Double

(((java.lang.Double)variable_sum_varSumCustgfcid.getOldValue()).doubleValue

()))));

^

C:iReport-0.1.0iReport-0.1.0bincustnew.java:718: unexpected type

required: variable

found : value

value = (java.lang.Double)

(((((java.lang.String)field_PROD_SUB_TYPE.getValue()).toString().equals

("ACD")) ? (new java.lang.Double

(((java.lang.Double)variable_sum_varSumCustgfcid.getEstimatedValue

()).doubleValue() += ((java.lang.Double)field_ACT_LIAB1.getValue

()).doubleValue())) : (new java.lang.Double

(((java.lang.Double)variable_sum_varSumCustgfcid.getEstimatedValue

()).doubleValue()))));

^

3 errors

 

 

at

dori.jasper.engine.design.JRCompiler.compileReport(JRCompiler.java:148)

 

at

dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:135)

 

at

dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:123)

 

at IReportCompiler.main(IReportCompiler.java:119)

 

Abnormal termination!

 

======================================

 

In the above error message, i don't understand what it means by

"required: variable" and "found: value".

 

Cud u plzzz help me in this regard???

 

Thanx & Regards,

Anuradha.

 

 

 

 

By: David Hardwick - dhardwick

RE: PROBLEM with Expression in VALUES FORM!!!

2003-08-19 08:43

It's trying to cast the String to a Double. Check your FIELD and VARIABLE definitions for field_PROD_SUB_TYPE

 

It's setting value to Double but it maybe having problems with the conditional statement, although both sides of the conditional statements return double. It maybe a problem with the brackets...I tried quickly to make sense of them, not sure if they are correct. Could you simplify your conditional statement to try and get past this error, then make it more complex once you get this working?

 

 

value = (java.lang.Double) ((

 

(

(

(java.lang.String)

field_PROD_SUB_TYPE.getValue()

).toString().equals("ACD")

 

) ? (new java.lang.Double (

( (java.lang.Double) variable_sum_varSumCustgfcid.getValue()

).doubleValue()

+= ((java.lang.Double)field_ACT_LIAB1.getValue()).doubleValue())) :

(new

java.lang.Double(((java.lang.Double)variable_sum_varSumCustgfcid.getValue

()).doubleValue()))));

 

 

AHHHHHHHHHHHHH!!! Yeah, I tried to make sense of these brackets, but it's too crazy...try to simplify this expression until this compiles, then add the complexity once you have the simple version working...then you'll know it's the statement that needs the attention and it's not something else.

 

daveh

 

 

 

 

By: Ryan Johnson - delscovich

RE: PROBLEM with Expression in VALUES FORM!!!

2003-08-19 09:46

I see two problems here - the smaller one is that you're trying to use the "+=" operator on a value instead of a variable, which is causing your error message.

 

The bigger problem is that you should be using a variable with calculation="Sum". I think what you really want is something like this:

<variable name="sum_varSumCustgfcid" class="java.lang.Double" calculation="Sum">

<variableExpression>

$F{PROD_SUB_TYPE}.toString().equals("ACD") ? $F{ACT_LIAB1}.doubleValue() : null

</variableExpression>

</variable>

 

According to the QuickReference (http://jasperreports.sourceforge.net/quick.reference.html#variable), the variable will store "the sum of the not null values encountered for the variable expression"

 

Good luck,

Ryan

 

 

 

 

By: Anuradha - anura

RE: PROBLEM with Expression in VALUES FORM!!!

2003-08-20 04:30

Hello all...

Thanx a ton for ur QUICK RESPONSE!

David Hardwick & Ryan Johnson's way to rectify those errors worked out!

Thank u once again...

 

Regards,

Anu.

====

Link to comment
Share on other sites

  • Replies 0
  • 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...