iReports 4.5.1 throwing error while using TABLE Report Element - jasper-reports

Hi I am getting the following error message while using the iReport designer Table Report Element:
Error filling print... java.lang.String cannot be cast to java.lang.Boolean
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
at net.sf.jasperreports.components.table.fill.FillTable.toPrintColumn(FillTable.java:116)
at net.sf.jasperreports.components.table.fill.FillTable$FillColumnEvaluator.visitColumn(FillTable.java:143)
at net.sf.jasperreports.components.table.fill.FillTable$FillColumnEvaluator.visitColumn(FillTable.java:130)
at net.sf.jasperreports.components.table.StandardColumn.visitColumn(StandardColumn.java:73)
at net.sf.jasperreports.components.table.fill.FillTable.evaluateColumns(FillTable.java:205)
at net.sf.jasperreports.components.table.fill.FillTable.evaluate(FillTable.java:98)
at net.sf.jasperreports.engine.fill.JRFillComponentElement.evaluate(JRFillComponentElement.java:88)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2021)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(JRVerticalFiller.java:616)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(JRVerticalFiller.java:538)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:263)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)
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:879)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)   
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
I am using Stored Procedures that returns a cursor as output.
I have placed this Table Report element in one of my group header.
thanks in advance
Meeza

Check in your style conditions if there's an evaluation with String. To ensure that everything works fine surround all the style conditions with new Boolean( ... ).

Related

Crystal Reports Formula: Help forming IIF Statement

I am working with Crystal Reports 11.5.10.1263 [CR Developer Type: Full].
I am familiar with Programming and SQL syntax in general and have worked with expressions in SSRS & MS Access but never in Crystal Reports.
Problem:
I modified the SQL in the Crystal report and it has had the desired effect - except in the last part of the report output - where the changes I made to the SQL do not have the desired effect.
The 'desired effect' is that when a field named 'FundNumber' has the values '2595', '2597' Then the field named 'Organization' should be assigned the value '41600'.
The Detail Record in the Report has the following three rows as part of its 'Formula':
+ IIf({Data.Payments} > 0, "+01W ", "-01W ")
+ Left({Data.FundNumber}+ SPACE(6),6)
+ Left({Data.Organization}+ SPACE(6),6)
I want to change the Data.Organization row to an IIF Statement that says [pseucode]:
IIf Data.FundNumber IN ["2595", "2597"] Then "41600" Else Data.Organization
I believe the Left() function is saying 'return the left 6 characters of [Data.Organization + 6 Spaces] ?? and that it has to do with the way the data is presented in the output.
I would appreciate help with creating the IIF statement for this.
I included the 'IIf({Data.Payments} ...' row in case that helps - as my google searches have turned up examples that use IF instead of IIF.
Thanks!
The syntax most of the time is the same as VB. Try
IIF({Data.FundNumber} = "2595" or {Data.FundNumber} = "2597", "41600", {Data.Organization})

Empty rows in report when using count function

I am using BIRT reporting with my mongodb datasource. I am trying to COUNT some events. COUNT function gives the correct value but there is big empty space at the end of the page depending upon the count value. If the count value is big then the rest of the page is empty and on the next page same record is coming e.g. :
In this Image the rest of the page is empty and same record is coming on the next pages also. It looks like empty spaces are being printed.
This is how my report looks like :
The COUNT function:
I have tried using SUM also but I get this error when I use SUM function instead of COUNT :
org.eclipse.birt.report.engine.api.EngineException: A BIRT exception occurred. See next exception for more information.
Can not convert the value of True to Double type.
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1245)
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1224)
at org.eclipse.birt.report.engine.executor.DataItemExecutor.execute(DataItemExecutor.java:101)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEmitterExecutor.execute(ReportItemEmitterExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.execute(HTMLAbstractLM.java:468)
Please help, thanks in Advance.
I got the issue to this problem. If we select "Hide Detail" Option from the group then this problem go away.

JasperReports: A dynamic table name using a variable? [duplicate]

This question already has an answer here:
Dynamic parameter of table name in Jasper [duplicate]
(1 answer)
Closed 3 years ago.
I have this problem with the JasperServer report I'm trying to create:
I have several db tables, named using a name and a date like this:
TABLE_NAME_YYYYMMDD
I want to be able to choose (and do a select from) the table which corresponds to the date submitted by the user from an ordinary Date input control.
I've tried creating a variable (called TABLE_NAME) which uses Java expressions for parsing the date like:
"MY_TABLE_" + new SimpleDateFormat("yyyyMMdd").format($P{RUN_DATE})
and when I print the value of the variable in the report it looks correct. But then I tried using that variable name in the SQL query like:
SELECT column1,column2.. from $V{TABLE_NAME}
but when I tried running the report in Jaspersoft Studio I got this Exception:
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Error executing SQL statement for: my_report_x.
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:511)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:486)
So it doesn't seem to be working.
I read about the case when the whole table name can be specified in a parameter, and you're supposed to use:
$P!{tableName}
First I tried using that '!' with the variable name like:
..from $V!{TABLE_NAME}
but I got the same Exception.
Then I tried creating a new parameter instead, where "Is For Prompting" is Not checked, and as default value expression I put the same expression as I used in my variable:
"MY_TABLE_" + new SimpleDateFormat("yyyyMMdd").format($P{RUN_DATE})
but I still get the same error when I try to run the report in Jaspersoft Studio.
Does anyone know if there is a way to solve this? -Preferably a way that doesn't take several days to implement since I don't have that time.
I'm using Jaspersoft Studio 6.1.1.final and running the reports in JasperServer 5.5.0.
You should be able to get this to work by wrapping the whole of your FROM expression in the parameter e.g.
<parameter name="pTableName" class="java.lang.String">
<defaultValueExpression><![CDATA["from MY_TABLE_" + new SimpleDateFormat("yyyyMMdd").format($P{RUN_DATE})]]></defaultValueExpression>
</parameter>
And then using this in your SQL as a string literal:
SELECT column1,column2
$P!{pTableName}
WHERE 1 = 1
I just found out what I did wrong.
I admit it was rather stupid, but I only tried running the report in the Preview mode in Jaspersoft Studio. That's when I got the SQL error.
But I assume that the Preview mode does not support dynamic decisions about which table to read from, because when I ignored the Preview errors and published the report to JasperServer, I actually could run it there!
I ended up using the $P!{TABLE_NAME} parameter where the value is what I tried earlier:
"MY_TABLE_" + new SimpleDateFormat("yyyyMMdd").format($P{RUN_DATE})
I can print as much as possible of my SQL here (meaning that I have to replace names since this is a work report) if you want to see it:
select c.column1,c.column2, h.column3 from $P!{TABLE_NAME} h, TABLE2 i, TABLE3 p, TABLE4 ca, TABLE5 c
where h.P_ID = p.P_ID and h.A_ID = ca.A_ID and ca.C_ID = c.C_ID and ca.SOME_VALUE = 1 and ca.OTHER_VALUE = 1
and i.I_ID=h.I_ID
and i.OTHER_ID=1
and h.VALUE_X > 0
order by c.VALUE_Y
So my advice to others who create Jasper reports is not to let yourselves get fooled by the fact that some things don't work in Preview mode. -That might just be the "preview limitations".

JasperReports Server: Input Controls error

My question relates to an error when generating a report.
In JasperReports Server created a Single Input Control Value but when you try to generate a report I get the error:
The server has encountered an error. Please excuse the inconvenience.
Error Message
net.sf.jasperreports.engine.JRRuntimeException: Invalid type java.lang.String for parameter SelectAsset used in an IN clause; the value must be an array or a collection.
In the preview iReport everything works flawlessly. I will put the value and generates a report.
if you mean a single value by "Single Input Control Value" it should not be a collection. So
Change your SelectAsset parameter type from java.util.Collection to java.lang.String
Then redeploy your report to the server then try again.

Crystal reports 11 : blank field bombs the report

I'm creating a invoice crystal report for sage mas 500 AR module. In it, I'm attempting to add the tarinvoice.balance field with the following formula:
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
I'm assuming that when the {tarPrintInvcHdrWrk.Posted} = 1 conditional statement holds FALSE, it doesn't attempt to pull the invoice field because when I remove the formula from the report, the form displays correctly without it.
When the conditional statement renders true in the report, the balance fields behaves correctly. However, with the formula renders FALSE in the CR form, the entire crystal report bombs and displays blank. Any ideas why or what I'm doing wrong?
Just tried setting everything to zero and the report still bombs. I'm starting to think its more of a query error in the report. I wish there was a way to exclude the field in the query when posted = 0.
With tarinvoice.balance removed when the posted = 0, the report works fine.
With tarinvoice.balance included and posted = 1, report works fine.
With tarinvoice.balance included and posted =0, report bombs.
I believe the conditional statement fails immediately if you encounter a NULL, so your formula needs to test IsNull({tarPrintInvcHdrWrk.Posted}) before it tests equality with "1".
You can change the way Crystal handles a null value for a value in a formula. At the top of the Formula Workshop there is a drop down box that usually says "Exceptions For Nulls".
Change this to the other option "Default Values For Nulls" and your formula should no longer bomb out. You used to be able to specify the what the default values applied were, but more recent versions of Crystal have these hard coded.
Search the help for "Null Treatment" for a table showing them.
I modified the formula to this:
if isnull({tarPrintInvcHdrWrk.Posted}) = FALSE then
if {tarPrintInvcHdrWrk.Posted} = 1 then
if isnull({tarInvoice.Balance}) = FALSE then
ToText({tarInvoice.Balance})
else
"0.00"
else
"0.0"
else
"0"
The crystal report still bombs.. Nevertheless, it does show "0" in the appropriate space.
I saw a suggestion on Exp.Exch to try putting the field into a variable before converting it to text.
e.g.
NumberVar InvoiceBalance;
If isnull({tarInvoice.Balance}) then
InvoiceBalance := 0
Else
InvoiceBalance := {tarInvoice.Balance};
If {tarPrintInvcHdrWrk.Posted} = 1 then
ToText(InvoiceBalance);
I also tried to recreate your problem, since I have see similar things before.
No luck though trying with CR 8.5 & XI R2. Perhpas it has to do with linked tables as well, since I only tried on a simple single table.
I have also seen similar behaviour when using a formula within a Running Total - they do not like nulls at all!
If you put {tarInvoice.Balance} directly on report (into details "debug" section - often needed, don't forget supress it in production :)), what values it displays or does report become empty?
Maybe you have Suppress If Blank section on your report. Try to put: Else " "
if isnull({tarPrintInvcHdrWrk.Posted}) or {tarPrintInvcHdrWrk.Posted}=0 then
" "
else
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
else
" "
I have trouble with this kind of field when making reports to export to excel. A field with no data in will pull all columns to the right of it over to "fill the gap".