<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_Report</id>
	<title>How to create a Report - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_Report"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Report&amp;action=history"/>
	<updated>2026-04-06T15:26:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Report&amp;diff=266&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Objetive == The goal of this how to is to describe the steps required to create a new report in Openbravo 3. The example explained is a simple report with a list of product...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_Report&amp;diff=266&amp;oldid=prev"/>
		<updated>2018-10-15T13:43:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Objetive == The goal of this how to is to describe the steps required to create a new report in Openbravo 3. The example explained is a simple report with a list of product...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Objetive ==&lt;br /&gt;
The goal of this how to is to describe the steps required to create a new report in Openbravo 3. The example explained is a simple report with a list of products.&lt;br /&gt;
&lt;br /&gt;
== Acknowledgments ==&lt;br /&gt;
Before starting make sure that you have read the [[Prerequisite Knowledge|prerequisite knowledge]] article. And you are confident with Openbravo [[Modularity_Concepts|modularity concepts]]&lt;br /&gt;
&lt;br /&gt;
== Setting up Jaspersoft Studio ==&lt;br /&gt;
&lt;br /&gt;
{{(!)| Jaspersoft Studio design client is supported since '''3.0PR15Q3'''. For older releases check [[#Creating_a_Reports_in_old_releases|this section]].}}&lt;br /&gt;
&lt;br /&gt;
You need to download Jaspersoft Studio, a graphical tool that allows you create and modify JasperReports templates (.jrxml files).&lt;br /&gt;
* Download [https://sourceforge.net/projects/jasperstudio/files/JaspersoftStudio-6.0.0/ Jaspersoft Studio] version '''6.0.0''' (v6.0.0). If using a higher version then it is necessary to ensure that the reports are generated for the '''JasperReport 6.0.0''' version. More info can be found [https://community.jaspersoft.com/wiki/compile-older-jasperreports-version-jaspersoft-studio here].&lt;br /&gt;
* On Linux: just download the .tgz file and uncompress it, execute the binary &amp;lt;i&amp;gt;Jaspersoft Studio&amp;lt;/i&amp;gt; located inside the main folder&lt;br /&gt;
* On Windows: Download and execute the .exe file&lt;br /&gt;
&lt;br /&gt;
=== Configuring Jaspersoft Studio===&lt;br /&gt;
Some properties of Jaspersoft Studio need to be modified in order to work properly. In short, you need to make sure:&lt;br /&gt;
* You modified the JasperReport property ''net.sf.jasperreports.awt.ignore.missing.font'' and set it to '''true'''&lt;br /&gt;
* '''Not''' use any '''Scriplet''' class&lt;br /&gt;
* Use '''Java''' as default expression language&lt;br /&gt;
&lt;br /&gt;
{{(!)| Jasperreport can be used in hw manager, but the version should be 1.0.2801 or higher}}&lt;br /&gt;
&lt;br /&gt;
=== Setting up Classpath ===&lt;br /&gt;
In Jaspersoft Studio, each report is supposed to be part of a project. So, you first need to create a new project (''File &amp;gt; New &amp;gt; Project''). &lt;br /&gt;
&lt;br /&gt;
The project has a classpath, and here is where you can add the jars you need.&lt;br /&gt;
&lt;br /&gt;
* Right-click on the project name: ''Properties &amp;gt; Java Build Path''&lt;br /&gt;
* Move to '''Libraries''' tab&lt;br /&gt;
* Click '''Add External Jars''' button&lt;br /&gt;
* Add the desired library.&lt;br /&gt;
* Click '''OK'''&lt;br /&gt;
&lt;br /&gt;
== Creating the Template ==&lt;br /&gt;
* Go to '''File''' &amp;gt; '''New'''&lt;br /&gt;
* Pick '''Jasper Report'''&lt;br /&gt;
* The '''New Report Wizard''' will be opened&lt;br /&gt;
[[Image:NewReportWizard.png|400px|thumb|center]]&lt;br /&gt;
* Select a Report Template, (&amp;lt;i&amp;gt;Blank&amp;lt;/i&amp;gt; following our example)&lt;br /&gt;
* Define a Report Name&lt;br /&gt;
* Define the file Location in the project. &lt;br /&gt;
&lt;br /&gt;
Later on we will copy this .jrxml file inside our Openbravo module that is going to keep our Report and the required configuration in the Application Dictionary also.&lt;br /&gt;
&lt;br /&gt;
* Define the Report Data Source: by clicking on &amp;quot;New&amp;quot;, a new database connection can be configured using the '''Data Adapter Wizard''' &lt;br /&gt;
* Click '''New'''&lt;br /&gt;
* Pick '''Database JDBC Connection''' and click ''Next''&lt;br /&gt;
* Fill all the fields&lt;br /&gt;
** '''Name:''' openbravo (or any name you like, e.g. pi)&lt;br /&gt;
** '''JDBC Driver:''' PostgreSQL (org.postgresql.Driver). In this case we'll use PostgreSQL&lt;br /&gt;
** '''JDBC URL:''' jdbc:postgresql://localhost:5432/openbravo where &amp;lt;i&amp;gt;5432&amp;lt;/i&amp;gt; is the port where PostgresSQL is running and &amp;lt;i&amp;gt;openbravo&amp;lt;/i&amp;gt; is the SSID of our database&lt;br /&gt;
** '''Username:''' tad (you can check your username/password in [[Openbravo.properties]] configuration file)&lt;br /&gt;
** '''Password:''' tad&lt;br /&gt;
* Click Finish button to generate the JDBC Connection&lt;br /&gt;
* Test your connection&lt;br /&gt;
* Save&lt;br /&gt;
[[Image:DataAdapterWizard.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
Now we have to configure the query: we are going to list the products present in the database. &lt;br /&gt;
* Right-click on the Report Outline menu, and select '''Dataset and Query'''. Here is where we have to set the query of the report and it is also possible to switch between the available database connections in case we want to test the query.&lt;br /&gt;
[[Image:DatasetAndQuery.png|300px|thumb|center]]&lt;br /&gt;
* The products are stored in the M_Product table &amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT m_product_id, value, name FROM m_product&amp;lt;/source&amp;gt;&lt;br /&gt;
* We have to add the fields based on your query which we want to use in the report, so we are going to add:&lt;br /&gt;
** m_product_id&lt;br /&gt;
** value&lt;br /&gt;
** name&lt;br /&gt;
&lt;br /&gt;
[[Image:DatasetAndQueryDialog.png|300px|thumb|center]]&lt;br /&gt;
* Click OK&lt;br /&gt;
&lt;br /&gt;
* Remember to clear the Scriptlet class and modify the Language for expressions&lt;br /&gt;
* Right-click on the Report Outline menu, and select '''Show Properties'''.&lt;br /&gt;
* In the report properties in the right, look for the following:&lt;br /&gt;
** Clear the Scriptlet class&lt;br /&gt;
** Choose Java as Language&lt;br /&gt;
* Save your changes&lt;br /&gt;
[[Image:ReportProperties.png|300px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
Let's now design the Report Layout&lt;br /&gt;
* Put a static text as report title: ''Product List''&lt;br /&gt;
* Place the fields in the '''Detail''' band and a title in the '''Column Header''' band&lt;br /&gt;
* Save your changes&lt;br /&gt;
[[Image:ReportLayout.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Switch to the '''Preview''' subtab to get a report preview&lt;br /&gt;
[[Image:ReportPreview.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
{{(!)|Note: It is recommended to use Dejavu fonts in jasper reports because this fonts support most of the characters in almost all languages​​. Besides, Dejavu typography is the family of fonts that Openbravo included in jasperreports-fonts library.}}&lt;br /&gt;
&lt;br /&gt;
=== Openbravo Runtime Environment ===&lt;br /&gt;
The standard reports in Openbravo (''src/org/openbravo/erpReports'') make use of several methods that reside inside the '''Openbravo Runtime Environment''', which cannot be executed at design time. For this reason, we provide the following '''[http://wiki.openbravo.com/w/images/4/47/Utility.jar .jar file]''' that encapsulates the following adapted methods of the ''org.openbravo.erpCommon.utility.Utility'' Class:&lt;br /&gt;
&lt;br /&gt;
* '''public static BufferedImage showImageLogo''': returns a logo image that is already included in the JAR archive&lt;br /&gt;
* '''public static String applyCountryDateFormat''': always returns the date formatted in this pattern dd-MM-yyyy&lt;br /&gt;
* '''public static DecimalFormat getCountryNumberFormat''': just returns the same DecimalFormat received as parameter &lt;br /&gt;
&lt;br /&gt;
For this, to be able to preview the standard Openbravo reports from '''JasperStudio''', it suffices just to import the .jar file into the classpath of the project within JasperStudio.&lt;br /&gt;
&lt;br /&gt;
=== Adding images and logos to a report using the ShowImage API ===&lt;br /&gt;
&lt;br /&gt;
You can use the Image BLOB reference to display an image for a specific report, or one of the Company logos in the application. First you need to add an image object to your report, set the expression class to &amp;quot;java.awt.Image&amp;quot; and the expression image to a call to the ShowImage function of the Utility class (if you want it to display a standard ImageBLOB image reference, that corresponds to a field added to a tab), or to the ShowImageLogo function if you want to display the logo of an Organization or Client.&lt;br /&gt;
&lt;br /&gt;
Images loaded with this method must not have alpha channel. A transparency layer is not supported by the function that loads images in Jasper Reports.&lt;br /&gt;
&lt;br /&gt;
* If you want to use the ShowImage function, you need to make the expression image look like:&lt;br /&gt;
** org.openbravo.erpCommon.utility.Utility.showImage(&amp;quot;IMAGEID&amp;quot;)       &lt;br /&gt;
IMAGEID needs to be the UUID of the image you want to show. You could set this value using a Jasper parameter.&lt;br /&gt;
&lt;br /&gt;
* If you want to use the ShowImageLogo function to show one of the logos, you have several options.&lt;br /&gt;
** This one will show the Company logo at System level:&lt;br /&gt;
*** org.openbravo.erpCommon.utility.Utility.showImageLogo(&amp;quot;yourcompanylogin&amp;quot;)&lt;br /&gt;
** This one will show the Company log at Client level (the client used will be the one the user logged at):&lt;br /&gt;
*** org.openbravo.erpCommon.utility.Utility.showImageLogo(&amp;quot;yourcompanymenu&amp;quot;)&lt;br /&gt;
** This one will show the Company logo at Organization level:&lt;br /&gt;
*** org.openbravo.erpCommon.utility.Utility.showImageLogo(&amp;quot;yourcompanydoc&amp;quot;, &amp;quot;ORGANIZATIONID&amp;quot;)&lt;br /&gt;
ORGANIZATIONID needs to be the UUID of the Organization whose log you want to show. You could set this value using a Jasper argument. An example could be '''org.openbravo.erpCommon.utility.Utility.showImageLogo(&amp;quot;yourcompanydoc&amp;quot;, &amp;quot;4387D62C6486481AB3D148442A6AD34E&amp;quot;)''' being 4387D62C6486481AB3D148442A6AD34E the organization ID.&lt;br /&gt;
&lt;br /&gt;
== Registering the Report in Application Dictionary ==&lt;br /&gt;
&lt;br /&gt;
=== Creating the Report ===&lt;br /&gt;
{{(!)| This feature is available from '''3.0PR15Q2'''}}&lt;br /&gt;
&lt;br /&gt;
From '''3.0PR15Q2''' it is possible to create a report using a process definition. For more information see [http://wiki.openbravo.com/wiki/How_to_create_a_Report_using_Process_Definition here].&lt;br /&gt;
&lt;br /&gt;
* Using the System Administrator role&lt;br /&gt;
* Using the quick-launch, open: '''Process Definition''' window &lt;br /&gt;
** You can find it in the menu: Application Dictionary &amp;gt; Process Definition&lt;br /&gt;
&lt;br /&gt;
* Create a new record&lt;br /&gt;
* Fill all required fields&lt;br /&gt;
** '''Module:''' Pick your module&lt;br /&gt;
** '''Search Key:''' OBPF_ProductList (Is a best practice to start with your module's [[Modularity_Concepts#DB_Prefix|DB_Prefix]])&lt;br /&gt;
** '''Name:''' Product List&lt;br /&gt;
** '''UI Pattern:''' Report (Using JR templates)&lt;br /&gt;
** '''Data Access Level:''' Client/Organization&lt;br /&gt;
** '''Handler''': use the default &amp;lt;i&amp;gt;org.openbravo.client.application.report.BaseReportActionHandler&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:ReportProcessDefinition.png|600px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
We must copy the .jrxml template file generated with Jaspersoft Studio into our module. When using Process Definition to generate a Report, templates need to be stored in the web folder of the module. In our example we place it in the following location: &amp;lt;i&amp;gt;/web/org.openbravo.platform.features/jasper&amp;lt;/i&amp;gt;&lt;br /&gt;
* Navigate to the '''Report Definition''' tab&lt;br /&gt;
* Fill the PDF template field with the location of the .jrxml file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ReportDefinitionTab.png|600px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
=== Creating the Menu record ===&lt;br /&gt;
* Using the System Administrator role&lt;br /&gt;
* Open the Menu window&lt;br /&gt;
* Create a new record&lt;br /&gt;
* Fill all required fields:&lt;br /&gt;
** '''Module:''' Your module&lt;br /&gt;
** '''Name:''' Name of the menu entry (Product List)&lt;br /&gt;
** '''Description:''' Description of the action related to the menu entry&lt;br /&gt;
** '''Action:''' Pick Process Definition&lt;br /&gt;
** '''Process Definition:''' Pick your Process Definition (Product List)&lt;br /&gt;
&lt;br /&gt;
[[Image:MenuProcessDefinitionReport.png|600px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
== Compiling ==&lt;br /&gt;
&lt;br /&gt;
After you have registered the report and menu entry in the Application Dictionary, you need to compile to generated the the necessary code.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;ant smartbuild&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the compilation has completed, refresh your [[How_to_setup_Eclipse_IDE|Eclipse project]], and restart your tomcat server.&lt;br /&gt;
&lt;br /&gt;
== Testing the Report ==&lt;br /&gt;
If you have completed all the steps, you should be able to open your Product List report form the quick-lauch, or menu entry.&lt;br /&gt;
&lt;br /&gt;
[[Image:ProductList.png|600px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
== Further Details ==&lt;br /&gt;
=== Layout ===&lt;br /&gt;
For information on how JasperReports handles the layout check [http://community.jaspersoft.com/wiki/making-html-xls-or-csv-friendly-reports Making HTML, XLS or CSV friendly reports]&lt;br /&gt;
&lt;br /&gt;
Also, a tutorial with the basics of how to design a report can be found [http://community.jaspersoft.com/wiki/designing-report-jaspersoft-studio here].&lt;br /&gt;
&lt;br /&gt;
=== Configuring Cell Type in XLS Reports ===&lt;br /&gt;
&lt;br /&gt;
Starting from '''3.0PR15Q3''', by default, Openbravo reporting engine exports the XLS data as strings. This is done in order ensure that the exported data can be read after opening the report with the vast majority of spreadsheet applications.&lt;br /&gt;
&lt;br /&gt;
If we want to have a particular format in a cell of our XLS report, and for example, display numbers inside a numeric cell, this default configuration can be overridden at template level. &lt;br /&gt;
&lt;br /&gt;
To override this configuration, the following must be done inside the .jrxml report template:&lt;br /&gt;
&lt;br /&gt;
# Add the '''net.sf.jasperreports.export.xls.detect.cell.type''' property with true as its value.&lt;br /&gt;
# Add a '''pattern''' for the text field that will be displayed in the XLS cell. With '''&amp;lt;pattern&amp;gt;''' tag a fixed pattern can be set and with the '''&amp;lt;patternExpression&amp;gt;''' tag it is possible to define a dynamic pattern.&lt;br /&gt;
&lt;br /&gt;
Please note that the decimal and thousands '''separators''' used for the numeric cells exported in this way, will be those defined inside the spreadsheet program itself (LibreOffice Calc, Excel,...). An example of report which applies this configuration can be found [https://code.openbravo.com/erp/devel/pi/file/7c6686c84928/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerExcel.jrxml here].&lt;br /&gt;
&lt;br /&gt;
=== Creating a Report Using Report and Process ===&lt;br /&gt;
'''Report and Process''' window was the habitual way to define reports before PR15Q2, as the '''Process Definition''' option was not available. In the following [http://wiki.openbravo.com/wiki/How_to_create_a_Report_with_iReport#Registering_the_Report_in_Application_Dictionary tutorial] you can find an example about how to create a Report in this way.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Reports in old releases ===&lt;br /&gt;
Before '''3.0PR15Q3''' version, another report design client was used, called '''iReport'''.&lt;br /&gt;
&lt;br /&gt;
To get more information about this and further details on reporting in old releases, you can go [http://wiki.openbravo.com/wiki/Reports_obsolete here].&lt;br /&gt;
&lt;br /&gt;
=== Report Compilation ===&lt;br /&gt;
{{AvailableFrom|3.0PR18Q3}}&lt;br /&gt;
&lt;br /&gt;
When printing a report in the application, it is previously compiled at runtime. The result of this report compilation is cached if there are no modules in ''in development'' status. &lt;br /&gt;
&lt;br /&gt;
Besides, it is possible to handle the state of this cache through a [http://wiki.openbravo.com/wiki/Retail:Monitoring_and_Management JMX] extension. Thus, this extension allows to:&lt;br /&gt;
&lt;br /&gt;
* See if the cache is enabled.&lt;br /&gt;
* Enable/Disable the cache.  &lt;br /&gt;
* See the list of reports whose compilation is stored in cache.&lt;br /&gt;
* Clear the cache contents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>