erikmarbad Posted February 16, 2022 Share Posted February 16, 2022 I am performing the following operation:$F{ANO}.equals((Integer.parseInt($F{ANO_ACT})-1) + "") ? $F{CAN} : new BigDecimal("0")where $F{ANO} is a String variable and $F{ANO_ACT} is another variable of type String but that I must convert to an integer to be able to do an operation with it, the part after the ? Ok, the problem is in the comparison, any idea why I get this error:net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{ANO}.equals((Integer.parseInt($F{ANO_ACT})-1) + "") ? $F{CAN} : new BigDecimal("0")Note: I am using version 6.18.1 of Jaspersoft Studio Community Link to comment Share on other sites More sharing options...
Solution bigalex Posted February 16, 2022 Solution Share Posted February 16, 2022 Variables ANO and ANO_ACT cannot be null and must be evaluated. Expression: $P{ANO}!=null? ($P{ANO}.equals($P{ANO_ACT}!=null ? (Integer.parseInt($P{ANO_ACT})-1+""): "ANO_ACT is Null")?$V{CAN}:new BigDecimal("0")): "ANO is empty"See example below:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="String to Integer" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c5f3f90c-4936-41e8-a034-b7a768ac9060"> <parameter name="ANO" class="java.lang.String"/> <parameter name="ANO_ACT" class="java.lang.String"/> <queryString> <![CDATA[]]> </queryString> <variable name="CAN" class="java.lang.String"> <initialValueExpression><![CDATA["CAN"]]></initialValueExpression> </variable> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="35" splitType="Stretch"> <textField> <reportElement x="80" y="5" width="430" height="30" uuid="d99f10a3-6103-4987-ab25-33932aa27d2c"/> <textFieldExpression><![CDATA[$P{ANO}!=null? ($P{ANO}.equals($P{ANO_ACT}!=null ? (Integer.parseInt($P{ANO_ACT})-1+""): "ANO_ACT} is Null")?$V{CAN}:new BigDecimal("0")): "ANO is empty"]]></textFieldExpression> </textField> </band> </pageHeader> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport> 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