Reporting on iSeries has come a long way. Traditionally, iSeries developers have to create reports using RLU, and then the RPG report program creates a spool file which the user then prints for his analysis. It’s a normal sight to see users printing bulk print-outs from the spool file. Then the need came for sending the reports via email, and there are lot of tools now to convert spool files to PDFs to send the reports to others. Though these converted reports to PDF will suffice, they do not have a professional look; they may lack a company logo and there is no way to show different colors, charts, internationalization, bar codes, different fonts, etc.

Though you can buy a vendor product to do all those things, why not try Jasper Reports for free? With Jasper, you can achieve all these things and create a professional looking report with any formats you wish (PDF, Excel, rich text format, XML, and CSV). However, to use Jasper, you will have to use java, and integrate Jasper in your java programs. And moreover, you will have to write SQLs to generate the data for your report. Thus, it might not be the best idea to write a complex SQL to generate a report (for example, a purchase order report), in order to replace or imitate a legacy reporting RPG program. In that case, the conversion tools (converting spool to pdf) will be a better option.

So, consider using Jasper for any new reports or for any small-to-complicated reports where not more than 2 or 3 files are needed, or for any files with less data.

Enough talk, soon I will show you how to get started with Jasper and create reports. But before that, a small overview.


First, you will have to download Jasper Reports from and
add the jasperreports jar file under the ‘dist’ to your classpath. Then,
go through the docs and the samples. The samples are runnable with ant.

Initially, it’s hard to understand the docs. The idea here is that you need to write an XML based on the jasper syntax. (ends with .jrxml – that’s the hard part). Then you need to compile it with jasper classes resulting in a binary file called .jasper. Then you invoke the filler classes to fill appropriate format of reports like PDF, or Excel or other formats.

For a simple example, we will have to:

  1. load the .jrxml (xml file ) and compile it (use JasperCompileManager.compileReport() methods , it returns a JasperReport Object, use this in the next step
  2. use JasperFillManager.fillReport(JasperReport Object,a Map object, a Connection object ) for filling up (or produce page prints) it returs a JasperPrint Object which you use in the next step.
  3. use JasperExportManager.exportReportToXXX(JasperPrint Object ,output file)

A simple source code will be like this:

JasperPrint jasperPrint = new JasperPrint();
Connection conn = null;
Map inputParameters = new HashMap();
inputParameters.put("sometitle","first report");
conn = your database connection you get from your driver (using jt400)
JasperReport jasperReport = JasperCompileManager.compileReport("input.jrxml");
jasperPrint = JasperFillManager.fillReport(jasperReport,
inputParameters, conn);
// for a pdf
JasperExportManager.exportReportToPdfFile(jasperPrint, outputFile.pdf);

The above source is simplified to just give the main idea and you can easily build above on this referring the api docs, using iReport to create the xml (.jrxml).

Using iReport to create the xml (.jrxml)

As I said before the difficult part would be creating the xml (*.jrxml) by hand. A typical xml format would be something like this:

<jasperReport name="FirstJasper" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="270" columnSpacing="15" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica"pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="8" isBold="true" isItalic="false" isUnderline="false"isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="8" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Comic_Normal" isDefault="false" fontName="Comic Sans MS" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="COMIC.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<reportFont name="Comic_Bold" isDefault="false" fontName="Comic Sans MS" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="COMICBD.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<parameter name="ReportTitle" class="java.lang.String"></parameter>
<parameter name="MaxOrderID" class="java.lang.Integer"></parameter>
<parameter name="SummaryImage" class="java.awt.Image"></parameter>
<queryString><![CDATA[SELECT * FROM Orders WHERE OrderID <= $P{MaxOrderID} ORDER BY ShipCountry]]></queryString>

and so on………..

And so, iReport comes to the rescue. Since creating the .jrxml would be mostly a one time job, it would be easy to use iReport. It is a fantastic open source tool in Swing and it will create the stand-alone reports in any format you wish, for quick testing and then embedding into your java application.

Download iReport from here.

It is an executable jar, needs JRE, and loads right away. It is resource intensive, so please make sure that you have more than 512 MB RAM on your machine.

To explain using iReport screen by screen there is an excellent step-by-step tutorial on devx.

iSeries Specific steps

The first thing is to configure the data source. Simply put the jt400.jar inside the iReport Folder/lib directory. Then, while creating a data-source, enter the appropriate as400 JDBC URL and test the connection. If it is not successful, then possibly it is not seeing the

Always use the Report Design wizard to create the reports. Note, iReport sometimes creates a line in the wrong place if you are using the Report Wizard; simply adjust the line or delete it.

Other tools apart from iReport

There are two other tools which can create the .jrxml file for you:

  • Jasperassistant
    If you use Eclipse then you can use Jasperassistant. It is a plugin to Eclipse and works the same way as iReport though not so easy as iReport.
  • Jasperedit
    A simple tool with not so much features as iReport and JasperAssistant.


Read the API docs, the devx tutorail and some good tutorials are available here . Buying the manual for jasper soft and iReport will explain some complex topics like scriptlets, embedding in server side and many more.

Republished, with permission, from

[tags]iSeries, jasperreports, Java[/tags]

About Rizwan Ahamed:
Rizwan has been working on the iSeries for the past 6 yrs and most of the time in WebSphere (portal and commerce environments) and interests in open source and scripting languages like PHP and has a bachelors degree in Electronics Engineering. His hobbies is working with his web blog and cooking with his family in spare time. He is currently working for a popular chain of bookstores in Middle East called JarirBookstore.