Report is one of the key USP for any ERP application. The more enhanced and flexible the reports are, more happy is the customer. In Openbravo, jasper reports provides us the flexibility to handle all this. iReport is one tool that can be used to create jasper reports. I have provided a simple example of how to add sub-report for an Openbravo Report using iReport.
Main Report:
Assume we have created a main report with the following query and layout.

Adding Sub Report:
The Sub Report can be created by adding the sub report icon as follows.
The sub-report can be added by drag and dropping the highlighted portion in the above screen shot. It will open the sub report wizard.
The sub report can be created in any one of the following three ways. Each way has different number of configuration steps.
1. A new sub report can be created using the wizard by using the "Create a new Report" Option. This will ask for all the options needed to create a new report including the report query. This will go through all the 7 steps.
The Sub Report expression can be any one of the following two options.
1. Through SUBREPORT_DIR Parameter
This will create a parameter SUBREPORT_DIR in Main Report. We have to point this parameter to the folder containing the sub report.
2. Through absolute path.
2. We can also call a already existing report as a sub report. This can be done by "Use an existing Report" option. We have to provide the path of the existing report. This will directly go to step 6 skipping the steps before that.
3. The last option will just create a blank sub report.
Adding Parameter:
In the Report Properties window, there is an option called parameter. This option enables us to add the parameter for that particular report.
Sub Report Query:
Note that you can see the parameter in the available parameters list in the above screen shot. We can also add the parameter through the "New Parameter" button in the above screen shot.
Importing Report in Openbravo:
For importing the report into openbravo, the jrxml files should be placed inside your module. For instance, if your module is XYZ with the Java Package com.fugoconsulting.XYZ, then the jrxml file should be inside the folder modules/com.fugoconsulting.XYZ/src/com/fugoconsulting/XYZ/erpReports/. Before importing the report into openbravo, we need to give the relative path for the sub-report and the images that we have added. This will make the report work in all systems irrespective of the path of the report. In order to give relative path, you need to add the following two parameters in main report.
1. BASE_DESIGN:
This parameter will be resolved at run time and will be pointing to your module folder(In our case modules/com.fugoconsulting.XYZ/src). The sub report expression must be modified as follows. This can be modified using the property "Sub report Expression".
2. BASE_WEB:
This parameter will be resolved to point the web folder at run time. This parameter is used to give the relative path for images. The sub report expression must be modified as follows.
Registering in Reports and Process:
Create menu and compile the application. The output will be,
For creating charts using iReport refer here.
Add a comment