Multiple unrelated in JasperReports - jasper-reports

I am using iReport with JasperReports. I want to include multiple subreports that have unrelated sql queries. I would like to be able to put these all on one report.
The problem I am facing is that when I leave the master report sql query empty, none of my subreports have any data. There isn't really anything that the master report sends to the subreports since they are unrelated. Basically how do you throw multiple unrelated reports together into one report.

In order for the Detail Band to show, you will need to fill the main report query, even if its just a dummy query, like say:
SELECT 'a' FROM DUMMY
This will make the Detail band appear, and with it all the sub reports.
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit menu, choose Report Properties, under More... tab, set the flag When no data to All Sections, no detail

Related

my table jasper report repeat the data many time [duplicate]

I am new to JasperReports, basically I want to put a subreport in a mainreport
The problem is that I put the sub report in the Detail band, so when I query a database that has multiple data the subreport will always repeat itself multiple times when I output the report to a pdf. I want a report that does not repeat itself regardless of how many data I have in the database that i connect with
I have searched the Internet and the solutions is to add
new Boolean($V{REPORT_COUNT}.intValue()==1)
in the print when expression attribute of the subreport, that does solve a part of my problem due to the fact that now my subreport only prints once but it still leaves some blank pages after my subreport is displayed
So I assume it is still repeating itself but just doesn't print the data because of the expression that I added , people say that the nature of the detail band is supposed to work that way and that I shouldn't put the subreport in the detail band, but if I put it in some other band I get this error:
Error filling print... Subreport overflowed on a band that does not support overflow.
The error above will happen if I have a lot of data to the extent that it may take up more than a page.
How do remove those blank pages? If I am ask to not put it in a detail band then what should I do? or what solution are there?
The Detail band will be generated as many times as the number of records you have in your main dataSet(populated by the top-level query).
If you want to keep the subreport in the Detail band, which is normal by the way, you can do one of these things:
either have a dummy query that returns only one record, so that the Detail band generates only once. Then, pass the report connection to your subreport. You may have done that already. This way you can run your query independently of the main report.
or leave the report as-is and add your printWhen expression ($V{REPORT_COUNT}.intValue()==1) directly on the Detail band, not on the subreport. Please note that this is just an ugly hack that may affect the report performance. Your main query still returns a lot of data that you don't use so you should consider the other options.
If you can move the subreport out of the Detail band, place it in a band that allows overflow like Title or Summary band. Then:
have your main dataSet's query empty so that no Detail band gets generated
set whenNoDataType="AllSectionsNoDetail" at the report level(in the <jasperReport> tag) so that all the other sections except the Detail get generated
exactly as in the first option above, pass the report connection to your subreport and work from there

The subreport repeats itself in Detail band

I am new to JasperReports, basically I want to put a subreport in a mainreport
The problem is that I put the sub report in the Detail band, so when I query a database that has multiple data the subreport will always repeat itself multiple times when I output the report to a pdf. I want a report that does not repeat itself regardless of how many data I have in the database that i connect with
I have searched the Internet and the solutions is to add
new Boolean($V{REPORT_COUNT}.intValue()==1)
in the print when expression attribute of the subreport, that does solve a part of my problem due to the fact that now my subreport only prints once but it still leaves some blank pages after my subreport is displayed
So I assume it is still repeating itself but just doesn't print the data because of the expression that I added , people say that the nature of the detail band is supposed to work that way and that I shouldn't put the subreport in the detail band, but if I put it in some other band I get this error:
Error filling print... Subreport overflowed on a band that does not support overflow.
The error above will happen if I have a lot of data to the extent that it may take up more than a page.
How do remove those blank pages? If I am ask to not put it in a detail band then what should I do? or what solution are there?
The Detail band will be generated as many times as the number of records you have in your main dataSet(populated by the top-level query).
If you want to keep the subreport in the Detail band, which is normal by the way, you can do one of these things:
either have a dummy query that returns only one record, so that the Detail band generates only once. Then, pass the report connection to your subreport. You may have done that already. This way you can run your query independently of the main report.
or leave the report as-is and add your printWhen expression ($V{REPORT_COUNT}.intValue()==1) directly on the Detail band, not on the subreport. Please note that this is just an ugly hack that may affect the report performance. Your main query still returns a lot of data that you don't use so you should consider the other options.
If you can move the subreport out of the Detail band, place it in a band that allows overflow like Title or Summary band. Then:
have your main dataSet's query empty so that no Detail band gets generated
set whenNoDataType="AllSectionsNoDetail" at the report level(in the <jasperReport> tag) so that all the other sections except the Detail get generated
exactly as in the first option above, pass the report connection to your subreport and work from there

Linking fields to subreport

In my main report I have some fields which I need to use in my subreport.
Right now I'm loading one csv file in both the main and the sub reports, but this seems to slow down the preview of my reports (I need these reports in a program). Eve if I use the preview in Crystal Reporst, it loads 3 times the same database, so I was thinking about linking the fields.
So I do Right Click on Subreport -> Change Subreport Links... and then I put the fields I want on the right side of the shown table. But when I do a preview of the whole report, in the subreport it shows only the first line and not all the values inside.
How do I manage to make the subreport show all the values of the fields?

Subreport Inner-join showing different results than same Main report inner-join

Crystal Reports is used to create templates for another application in my case. A value is passed from the other application to a specific table, which I can then, in crystal, use with inner joins to other tables to specify the values on the rest of the report.
This has worked well in situations where I have not being using subreports. In my main report, I have 4 tables inner joined, and they are correctly being passed a certain value from this program.
My problem lies with attempting to create a coverpage for this particular report. I needed a detail section on the coverpage, so I looked to creating a subreport on the report header of the main report. I used the same tables in the subreport itself with the same inner joins. It receives extra values. This is the exact inner join design with the same tables from the main report, yet it is showing different results.
Does anyone have a solution to this? I am particularly new to crystal reports, and have just avoided subreports to avoid deeper complication. I believe I may just be able to pass the criteria value from the main report through a shared variable or parameter as an alternative to my current attempt, but I am not sure how.
Thanks.
It sounds like you are taking the right approach by using a subreport. You did add the parameter to the subreport and linked it through from the main report?
I suggest you view the SQL query for both the main report and subreport to identify the discrepancy.

Is it possible to load a rpt to a subreport dynamically?

I would like to create a kind of master report, with 2 sections. The first will contains a subreport that will always be the same. The other section will contain a subreport that would be loaded with differents .rpt files, depending on some business rules.
I tried to use something like:
report.Subreport["subReportName"].Load("path to desired .rpt")
But Crystal return an error saying it is an invalid operation. There is another way to do that?!
Have the main report load all the subreports all the time, but only display the one you want conditionally.
Hide the subreports you don't want conditionally, in other words.