ADempiere/JasperReports Integration HowTo

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Jasper Report with


Jasper Report is a powerful reporting tool that creates printable documents (in PDF and other well known formats) using predefined schema and by extracting data from database.

You can use it to print invoices or create reports of your company in Adempiere. There is a wysiwyg editor for Jasper Reports called iReport so reports can be designed easily.

Integration with ADempiere was done by Trifon helped by Alejandro, Johannes and Heng Sin. The original report starter was re-engineered by Schmidt András so that it supports subreports and including pictures better. This report integration is not in the production version of Adempiere yet but may be in later versions.

If you want to integrate to older ADempiere versions, take a look here. ReportStarter2 is based on ReportStarter shares concepts but it is not compatible with it.

Technical documentation and howto

ReportStarter2 integrates Jasper report into Adempiere. The usage scheme is the following:

  1. ReportStarter2 sets $P{RECORD_ID} to the id of the selected record.
  2. ReportStarter2 calls the report with the datasource set to the Adempiere database.

Step by step:

  1. Create your jasper report using your favourite tool. Eg. iReports (or vi text editor :-)
  2. Your main report file _must_ be called "report.jrxml"!
  3. If you have subreports then you have to reference them without path or with path: $P{SUBREPORT_DIR}+"anything.jasper". When you reference a jasper file
  4. All report (subreport) files get the extension "XYZ.jrxml". All files that's name ends with .jrxl will be jasper compiled before executing the report. The compiled file will be called "XYZ.jasper"
  5. Subreport references must be in form "XYZ.jasper"
  6. Pictures also must be referenced with relative path.
  7. The record the report is about (for example invoice id) is got in parameter called "$P{RECORD_ID}" this is the way it have to be referenced in the Jasper file. When testing in iReport you can set this parameter by hand on the GUI.
  8. All files of the report have to be collected under a single directory. Sub directories are allowed.
  9. All files of the report must be zipped into a single file. Name of the zip file can be anyting.
    1. Don't zip .jasper files. Only pack the .jrxml's.
    2. WARNING: Current implementation uses the zip file's name for the name of the temporary directory used to unzip and compile the report. Don't use the same zip file name for two processes they will clash. I plan to fix this later.
  10. As role System Administrator create a process in Adempiere: (Application Directory / Report & Process)
    1. Name your process as you like
    2. (Java) Class name: - this is our own class
      1. JasperReport: set the URL of the report zip file. URL types currently supported:
        1. attachment:// means that the file is an Adempiere attachment of the process.
        2. file:// means that it is a file on the machine that runs the report.
      2. If you use attachment you have to attach the file to the process. Use the button attachements on the form to upload attachment to the process.
      3. Fill the field called JasperReport so your report will pop up on the print format form as an option.
      4. The attached file will be stored on your Adempiere server database so every client will use the same file. The client will check the file for changes before each usage of the process so it will always use the latest one.
  11. Now don't use superuser@System, but admin@yourcompany.
  12. Create a new print format.
    1. Select the table for the format. Eg. if you create an invoice format then select "C_Invoice_Header". This is used by Adempiere as a key on which forms the print format will be shown as an option. If you select "C_Invoice_Header" then your format can be selected as format for invoices.
  13. Select your shiny new process in the field Jasper process for invoice printing format.
  14. Create an invoice to test it!