
By Ravi M | Article Rating: |
|
December 11, 2009 12:17 PM EST | Reads: |
29,350 |
SAP (Business Objects) has recently released Crystal Reports for Eclipse version 2.0 to provide reporting solutions for Java-based applications. This is available as free to use (within an organization) and has the advantage that it is built on the most tested and reliable component (Java Reporting Component in Crystal Reports) that has been in market for quite a few years now. This article discusses the features of CR4Ev2.0, usability of its designer and API, and starting off with an overview of Crystal Reports product architecture.
Crystal Reports - Product Overview
Crystal Reports is delivered in three editions with features added upon with each edition and its core feature diagrammatically depicted in Figure 1.
Crystal Reports Developer and Server editions have SDKs for Report Integration that aid in report viewing, printing and exporting in applications, customizable report viewers and report creation APIs. In case of Developer editions, the report processing resides within application and in Server editions it can be offloaded to a Reporting Server.
There are two sets of SDKs available for each of SAP (Business Objects) supported technology platforms (Java and .NET) and for Java these are namely:
- Java Reporting Component (JRC): This is used to perform report processing within application.
- Report Application Server SDK (RAS SDK): This is used to work with Report Application Server where report processing is done on the server and Java application uses RAS SDK for communication with the server.
JRC shares many classes with the RAS SDK, and the JRC-specific classes are thin wrappers around RAS classes.
CR4E vs JRC
JRC was introduced in Crystal Reports 9 and is a reliable component in Crystal Reports product. Crystal Reports have refined this component and bundled it as a separate package known as CR4E, which contains Crystal Reports for Java (CRJ) and Crystal Reports Designer components. The designer component is available as a plug-in to Eclipse and is used for designing and previewing reports. The Crystal Reports for Java component is used for the runtime generation of reports within Java applications.
RAS SDK is the client component for the RAS server-client reporting solution, where the SDK communicates with the RAS server for report processing. With the CRJ SDK, the same classes as that of RAS SDK are used but report processing requests are sent to an in-process Java Report Engine.
A great enhancement of CRJ over JRC is the introduction of RAS-type report creation and modification capabilities. With the CRJ, it's possible to programmatically modify a report on-the-fly: create new fields, introduce new data connections and tables, modify images, add lines and boxes, etc. Anything that can be done to a report using the CR4E embedded designer can also be done programmatically using CRJ as the designer uses the same SDK.
Few points in comparison between CR4E and JRC are jotted in Table 1.
Features of CR4E
Already, few features of CR4E are exposed through its comparison with the JRC above, the following makes the list complete:
- Ability to integrate reporting into Java-based web or desktop applications.
- Provides SDK that enables report creation and modification within Java code.
- Helps Java developer switch on to the Report designer role easily in reporting projects.
- POJO can also be used as a data source for reports.
- Accesses all major databases from within Eclipse IDE as report template data source.
- Supports for all major operating systems and browsers.
- Comes with extension SDKs to extend and enhance the default Eclipse editor.
- Use of Eclipse Update Manager to check and install updates automatically.
Aspects of CR4E Designer
CR4Ev2.0 is provided as a plug-in for Eclipse IDE and works for an Eclipse version greater than 3.4.1. Figure 2 captures the commonly used aspects in the designer and same is detailed further.
Layout tab: Layout tab is the designer view and has the palette with all reporting controls. The controls from palette can be dragged & dropped onto the designer area at the required position.
Preview tab: Preview tab is used to preview the report designed in layout view and the report can also be directly edited in this view. The data source for the report is changed using the ‘Set Datasource Location' menu item under ‘Crystal Reports'.
Datasource Explorer wizard: This wizard is used to create a connection profile for the datasource used in the reports. The CR4E supports relational databases, flat file, web services, XML and POJO as datasources. Once the connection profile is created, the required objects in datasource can be dragged & dropped onto the data view (tab).
Field Explorer wizard: This wizard displays the database objects in the data pane for use in the report. Also, parameters and formulas are created using this view and then placed on to the report layout.
Usage of CR4E APIs
After creating report templates using CR4E designer, the common reporting need is to generate reports dynamically from report templates based on the parameters passed to it. This scenario is walked through below to demonstrate the use of CR4E APIs for generating reports from a standalone Java application (see Figure 3).
The use of CR4E API programmatically in each of this task is explained below:
1) Initiate
Report processing is done by Crystal Report Java component (and not by Report Application Server) and this component is initiated as below:
ReportClientDocument boReportClientDocument = new ReportClientDocument();
boReportClientDocument.setReportAppServer (ReportClientDocument.inprocConnectionString);
2) Load
Next task is loading the report template for report generation as below:
boReportClientDocument.open("SampleReport.rpt", OpenReportOptions._openAsReadOnly);
3) Read
This task is a two-step process; one is to set the connection information for datasource and next is to set the values for input parameters in the report.
a) Set connection information: In most cases, the datasource configured in report template during report design will not be the same one used by the report generation application. So, the datasource connection information for the report template needs to be replaced thro' the following lines of code:
dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams);
dbController - DatabaseController object that is retrieved from ReportClientDocument object for managing database connections
oldConnectionInfo - ConnectionInfo object that is retrieved from DatabaseController object and contains details of existing datasource such as database URL, Server Type, username, password etc.
newConnectionInfo - New ConnectionInfo object that is constructed to replace oldConnectionInfo object
b) Set input parameters: Data displayed on the report is restricted based on the parameter values supplied to the report, same is programmatically done below:
ParameterFieldController parameterFieldController =
boReportClientDocument.getDataDefController().getParameterFieldController();
parameterFieldController.setCurrentValue("","a","123");
4) Export
The final step is to export the generated report in required format as in lines of code below:
PrintOutputController printOutputController =
boReportClientDocument.getPrintOutputController();
ByteArrayInputStream byteIS = (ByteArrayInputStream) printOutputController.export(ReportExportFormat.PDF);
The report stream can be written to a file etc. as needed.
An important point to note during development using CR4E is that it contains both JRC and CRJ APIs and both the APIs have most classes with same name so import statement is critical in determining which APIs are used. To use CRJ, import classes under package name:
com.crystaldecisions.sdk.occa.report.application and for JRC, package name is com.crystaldecisions.reports.sdk
Conclusion
The design and development of reporting solution using CR4E is done using the designer plug-in for Eclipse and Crystal Reports for Java components that are enhanced from reliable Java Reporting Component of Crystal Reports. Modeled with ease of use, intuitive report design and toolset, simple licensing and support from SAP (Business Objects) helps CR4E to be considered as a reporting solution for Java projects.
Reference
Published December 11, 2009 Reads 29,350
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Ravi M
M.Ravi is a Senior Technical Architect, specialized in providing architecture and design solutions on broad of spectrum of areas such as JEE, SOA, ESB, BI, CRM & SAS.
![]() Nov. 11, 2018 04:00 PM EST Reads: 3,170 |
By Pat Romanski Nov. 11, 2018 11:45 AM EST Reads: 2,284 |
By Elizabeth White Nov. 10, 2018 11:45 PM EST Reads: 2,064 |
By Pat Romanski Nov. 10, 2018 10:00 PM EST Reads: 3,206 |
By Pat Romanski Nov. 10, 2018 01:00 AM EST Reads: 2,941 |
By Pat Romanski Nov. 9, 2018 04:45 PM EST Reads: 2,282 |
By Yeshim Deniz Nov. 3, 2018 05:00 AM EDT Reads: 4,027 |
By Yeshim Deniz Nov. 2, 2018 03:00 PM EDT Reads: 3,210 |
By Elizabeth White ![]() Oct. 30, 2018 03:45 PM EDT Reads: 14,062 |
By Zakia Bouachraoui Oct. 30, 2018 11:45 AM EDT |