How to print report more than once with difference invoice numbers - jasper-reports

Using iReport 4.5.0, I have designed the report to print invoice by giving the invoice no as parameter. The report contains Title, Page header, Detail (items in the bill), Summary, etc.
Every thing working fine. Now the client asking to print more than one invoice i.e from the list they will select more than one invoice and they want to print all?
Any idea? Do I need to change the entire report into detail section or any other idea

You can do a few things.
You can keep the report as an individual report, and execute each report with a list of Invoice Numbers. You will need to handle this in your application.
where invoice.num = $P{invoicenum}
OR
Modify the report to be a batch report that takes in a list of Invoice Numbers. To provide a list your application will need to generate a SQL appropriate list of invoice numbers/IDs what have you.
where invoice.num in ($P!{invoicenums})
OR
Create a Batch Report that uses your Invoice report as a subreport, run a SQL query based on your criteria in the Batch Report, and use the Invoice Report as a detail band that gets passed Invoice Numbers.

Related

Linking tables where record in one table has a prefix and other does not

I am creating a report which will allow me to reprint invoices using information from two different tables from Sage 300 accounting/job costing sofware.
I have one table that has an invoice number of "123456" and another table that has an invoice number of "SM123456" referring to the same invoice. The second tables adds the "SM" so that it knows that the invoices was sourced from a particular module. Is there any way to link these?
I have tried creating a report with a formula to remove the SM from one of the tables so that it can be linked to a subreport. However the subreport that I want to print is already using subreports and the second tier subreports are not printing data that is needed.
I am open to any other suggestions.
Thank you,

I Want to Print 1 report in two copies(2 Prints ) with same data in crystal report having Subreport?

Normally if we have report without any sub report in it, it is easy to print twice the report by adding same report in page footer as sub report . But if report contains already subreport than it is not possible to again add subreport in it. So how can we Print such report twice in crystal report.
It must exist a better solution, but here it goes two workarounds:
Alternative 1:
Turn your main report into a subreport (with its child subreport) and duplicate it in a brand new main report.
Advice: subreports use to perform poorly, but if your data is not large, it is ok.
Alternative 2:
If you can easily manipulate the data source (for example, if your generating a dataset through code), use the details section for your report, insert an extra table in your data source where the number of lines is the number of "copies" that you want to print. Let your main table join with this "fake" table without links. The result will be a cartesian product, so you will get the number of copies you want.
Extra note: Crystal let you use another rpt file as a subreport. Maybe you can use this feature to solve your problem. Personally, I don't like this feature, because it does not behave like I would expect by intuition.

Repeat main report rows per each subreport row

I have a JasperReports's report already implemented using below data structure which prints a main record along with its subreport records. The main and the subreport are placed in the same detail band and the subreport uses the JRBeanCollectionDataSource($F{employees}) as its data source expression $F{employees} being the collection field on the main report data type Company.
Company
Name
Location
Employees
Employee
ID
Fullname
etc.
The question is if there is an option in report to repeat the main report columns (Name, Location..) for each subreport record I have for a certain Company?
Basically, I need repeated records in the main report.
I know this is ugly and may look pointless but that is the Business Requirement! Most importantly, I don't want to touch the existing data structure as it's more complex in real case than my example.
Any hint (could be even a hack in JasperReports) is highly appreciated.
Note: I'm using iReport 3.7.3 editor.

Crystal Subreport Common Headers

Maybe someone can Help me find the right technique.
I have a number of Crystal Reports that I am updating (Crystal Reports XI).
These reports each have an SQL Function associated with each that either retrieves records from the database (if any meet criteria) or returns an Empty Dataset (which happens daily).
These are executed in a batch process and directs the output to a PDF file which is emailed to users.
I am relatively new to Crystal Reports.
I am attempting to use a common SubReport to format/gather data for the Headers/Footers used in these documents. So far - most of this is working as I would expect. This allows me to use a single SubReport to generate the same Header/Footer in multiple reports (at least that's my goal).
However - I added a Report Footer section to the Main Report - my plan with this was to generate a Report Footer that would contain the following information:
A static Text Message that reads " --- END OF DOCUMENT ---"
The Report Title of the "Main Report"
The Date and Time that the Document was generated and Total Number of pages.
Sounds pretty simple.
So SubReport is named: "END-OF-DOCUMENT-SUBREPORT"
I used the "Special Fields" Data Date, Data Time, & Page N of M
Since the "Special Field" Report Title is returning me the "END-OF-DOCUMENT-SUBREPORT" value I used a Parameter field to pass the Report Title value from the Main Report to the SubReport.
This all works fine - HOWEVER - with the addition of the Linked Parameter Field from the Main to the SubReport - when I execute the report to generate the document - the SubReport ends up showing a blank Report Footer - that I can click on to reveal the "END-OF-DOCUMENT-SUBREPORT" in another Tab.
Without the Parameter field - it didn't do this and the information from the SubReport appeared on the last page of the document.
Is this a standard behavior of Crystal?
I'm not sure how to Suppress the "Drill Down" feature and still display the Report Section.
You can pass variable between you Main Report and sub Report. You can also create variable and assigned them to a sub report. As aMazing mention, creating Header and Report Footer sub report is not common. It is even messy. If you want something generic, I will create a report template that you will use in the future.
Have a good day!

Multiple Crystal Report to be printed on same report

I have a crystal report that takes only about 1/3rd of the report space.
I have field read from the database which is an integer value.
I wish to print this report number of times as read from the database on the same page.
Any idea on how this can be achieved?
I can only use crystal report for achieving this.
Thanks in advance.
You can create another report and add your current report as a subreport multiple times
Lan is correct, build another report and add your current report as a subreport.
Here's the trick:
On your main report, have it make a list of all of the items that
you'd like to run the sub-report on.
On your sub-report, add a parameter called "itemNumber" or something like that. Then change your Subreport Links so the new "itemNumber" parameter is linked to the item on your top level report.
Now hide the field on the main report but leave the
subreport visible.!
This should make your report run for all items at one time.
In this case you can create a table with the maximum number of prints you will ever use. For example if you think you might need to print the report 100 times your table should contain records from 1 to 100. So lets assume this is the case- create a table , name it Copies and add a field CopyNo. Create a 100 records and set CopyNo from 1 to 100. Create the a main report based on Copies table - the record selection formula will be something like :
Copies.CopyNo<=#NumberOfCopies
#NumberOfCopies is a parameter , which you can set in order to control the printed copies. Create your actual report as a subreport and place it in the details section of the main report. When you run the report it will ask you for the number of copies and when you insert it, will print the same subreport as many times as the number you provide.