Hi all,
I am trying to modify an existing jasper report that is used in our Fishbowl Inventory (Firebird database).
One of the fields returned from the SQL query will return a value that is a alphanumeric part number which may or may not be suffixed with an _R## value (where ## will be a 2 digit number). An example would be 395521_R75 or 594TIMB543_R25, etc.
When we display this value in the final report, we want to truncate the _R## value and only display the 395521, 594TIMB543, etc.
Is there a way to accomplish this with iReports 5.6.0 ?
5 Answers:
Hello,
At least one of the problems lays within the curly brackets. Expressions like $F{PRODUCTNUM.split("_")[0]} don't represent valid entities in JasperReports. Try to use $F{PRODUCTNUM}.split("_")[0] instead, and see if the issue still occurs.
Also, make sure the PRODUCTNUM field is of type String in order to apply the split() method.
And one last thing: make sure the <variable > tag is properly closed (the </variable> closing tag should be also present in your JRXML file after </variableExpression>).
I hope this helps,
Sanda
Hi all,
So after looking at the suggested answers, it seems like the .split method offered by Sandra is the most point on solution, since the _R## value may or may not exist.
However, the issue I've encountered is that the report is using a $V (variable) instead of a $F (field), so the expression field isn't available.
I tried appending the .split method right onto the $V in the report detail and that didn't work, so I started poking around in the XML and found this:
<variable name="ItemNum" class="java.lang.String">
<variableExpression><![CDATA[($F{KITPARENTLINE} == null ? "" : " ") +
($F{PRODUCTNUM} == null || $F{PRODUCTNUM.split("_")[0]}.length() < 1 ?
"" :
($F{CUSTOMERPARTNUM} == null || $F{CUSTOMERPARTNUM}.length() < 1 || !$P{IncludeCustomerPartNumbers} ?
$F{PRODUCTNUM.split("_")[0]} :
$F{PRODUCTNUM.split("_")[0]} + " (" + $F{CUSTOMERPARTNUM} + ")"))]]></variableExpression>
The above results in a compilation error, so obviously not the correct approach. Sorry if I'm missing something obvious, I just got thrown into this project and am really unfamiliar with Jasper reports (and report writers in general).
How should I proceed?