Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Implementing WebSphere Commerce operational reports with Crystal Reports

Bin Zhou (zhoubbin@cn.ibm.com), Software Developer, IBM
Bin Zhou is an Advisory Software Developer in the IBM Beijing Lab, China. His main focus is on WebSphere Commerce contract and pricing components development.
Dorothy Wu (dwu@us.ibm.com), Web Editor , IBM
Author photo
Dorothy Wu is the editor of the WebSphere Commerce zone at the IBM Silicon Valley Lab in San Jose, California. She also works on developerWorks WebSphere community features, such as Meet the experts.

Summary:  This tutorial shows how to implement operational reports using embedded Crystal Report tools and a Rational® Application Developer plug-in, then develop and test the reports in the WebSphere® Commerce Toolkit.

Date:  18 Jul 2007
Level:  Intermediate PDF:  A4 and Letter (1507 KB | 38 pages)Get Adobe® Reader®

Activity:  7461 views
Comments:  

Before you start

WebSphere Commerce analytics are best presented in a visual format using a reporting tool that is standardized. Ideally, you develop these reports easily in an integrated development environment (IDE), such as WebSphere Commerce and Rational Application Developer V6. Currently, the WebSphere Commerce reporting framework is used out of the box for both business intelligence and operational reports. This reporting framework displays data in tabular, not graphical, format, which is not ideal for business users who need to visualize results they are trying to analyze.

In this tutorial, you will choose an operational report named Order Status Report and use the embedded Crystal Report tools to implement the report using the IDE. The embedded Crystal Report tools have a Rational Application Developer plug-in so that you can finish designing, developing, and testing the report in the WebSphere Commerce Toolkit.

This tutorial shows how to implement the order status report for WebSphere Commerce using Crystal Report tools, and outlines briefly the strengths of each reporting tool. It also explains how you can use these same steps to extend existing reports or create new reports.

WebSphere Commerce development environment overview

WebSphere Commerce development environment includes tools you need to create customized code and perform Web development tasks. It builds on top of Rational Application Developer, which is the core development environment from IBM. It helps you optimize and simplify Java™ 2 Platform Enterprise Edition (J2EE) and Web services development by offering best practices, templates, code generation, and the most comprehensive development environment in its class. This integrated development environment includes integrated support for Java components, enterprise beans, servlets, JSP files, HTML, XML, and Web services all in one development environment.

WebSphere Commerce report framework overview

The WebSphere Commerce reporting framework provides generic, customizable reporting functionality for a WebSphere Commerce site. The framework generates reports using data contained in the production database, and displays the reports in real time. The framework consists of a generic controller command, a data bean, and a generic view that displays the result. You can customize the framework by adding valid SQL queries, and defining JSP files used to request and display the generated reports.

Reports are accessible from the WebSphere Commerce Accelerator. Consequently, each report requires a number of associated assets. While the report itself consists of data represented in a tabular format, the underlying assets consist of the report identifier, an SQL query, access control elements, and so on. The report request launches a controller command on the server. The controller command calls tasks to set the generic view, unless the report specifies a particular view. The command also sets a number of required variables, and returns this data to populate the ReportDataBean in the target JSP file. Access control for the reports is set on the views which request (input) and display (output) the report. The results returned from the database are stored in the data bean as a vector of hashtable. Finally, the JSP file displays the report. If the report is empty, the JSP file displays a generic text string instead.

Each report has an input view and an output view. The purpose of all input JSP files is the same. They share the same look and feel; they request different input criteria from a shared input widget pool. On the other hand, output views have common structure and formats. Based on the nature of the reports, all reusable parts of the report JSP files are built as sharable components.

The report framework also supports multiple types of relational databases (RDB) products. Developers can specify the SQL that was used to generate report data with a common style, then the report framework composes the SQL according to a certain database type, and outputs the final SQL statement that is executed. Figure 1 illustrates how the report framework outputs a report.


Figure 1. WebSphere Commerce report framework
Figure 1. WebSphere Commerce report framework

As Figure 1 shows, the user enters query criteria into the report input view. The report control center gets the input parameter from the input view, and reads, analyzes, and formats the xml file that defined the current report content. The report control center generates the SQL statement according to the user's input and current database type, and then pushes this SQL to the database. Lastly, the report control center fills the result returned by the database into the report data bean and parses it to the output view. The output view displays the content of the report in tabular format.

Crystal report overview

Crystal Reports is a popular report tool. It is designed to work with multiple data source and helps users to analyze and interpret important information. Crystal Reports make it easy for users to create simple reports, and it also has comprehensive visible tools users need to produce complex or specialized reports.

In Rational Application Developer, you can use embedded reporting to build Crystal Reports into Java applications. The embedded reporting scenario uses the Java Reporting Component (JRC) and Crystal Reports Viewers Java SDK to enable users to view and export reports in a Web browser. They provide the functionality that creates and customizes a report viewer object, processes the report, and then renders the report in DHTML. The JRC keeps report processing completely internal to the Java application server. The JRC allows you to process Crystal Reports report (.rpt) files within the application itself, without having to rely on external report servers. It has the following advantages:

  • Provides a 100% Java reporting solution.
  • Dynamically pushes runtime data to a report.
  • Programmatically changes the database location for a report.
  • Exports Crystal Reports report (.rpt) files to RTF and PDF formats.

Converting to Crystal Reports overview

This section discusses how to convert a WebSphere Commerce operational report into a Crystal Report. Each WebSphere Commerce report has a corresponding xml file to identify the SQL that was executed to query data for the report. To support multiple database production as well as provide flexibility, this SQL, which we call "rough SQL", cannot be executed directly because it includes some self-defined functions such as "$Date()" or "$Time()". These self-defined functions are replaced by real database functions in the report framework according to the current type of database. The rough SQL also includes some variables that are replaced by real values according to the user's input. Before fetching data from the database, the report framework replaces all variables and self-defined functions and makes it as a final SQL that is executed in the database.

To convert the WebSphere Commerce report into a Crystal Report, you need to create a rtp file for the Crystal Report using the rough SQL from the WebSphere Commerce report. This make them have the same columns and report format. Then you need to fetch the final SQL from the report framework and execute the query, and set the result set from the database as the new data source of your Crystal Report. This makes the Crystal Report have the same dynamic content with the WebSphere Commerce report.

By default, the report framework does not provide the public interface to return the final SQL, so you need to customize the report framework and add the interface to return the final SQL statement.

You also need to execute the final SQL statement from the report framework and get the report content data from the database. This is done by one of the new data beans, CrystalReportDataBean.

Finally, you need to set the result set returned from CrystalReportDataBean as the new data source for the Crystal Report. You can implement this by calling the API of JRC (Java Reporting Component). The code looks like this:

DatabaseController.setDataSource(java.sql.ResultSet data, 
java.lang. String oldTableAlias, java.lang.String newTableName)

This method updates the data source used by the Crystal Report with the specified java.sql.ResultSet data set. Figure 1 shows a dynamic list that is used to display the list of defined subsidies.


Figure 2. Solution of converting WebSphere Commerce report into Crystal Report
Figure 2. Solution of converting WebSphere Commerce report into Crystal Report

Figure 2 shows how the WebSphere Commerce report framework and WebSphere Commerce tools framework work with embedded Crystal Report tools, and how they convert WebSphere Commerce reports into Crystal Reports.

The blue arrows demonstrate the flow of how WebSphere Commerce reports were generated as described in the WebSphere Commerce report framework overview section.

The green arrows demonstrate the flow of how embedded Crystal Report tools get necessary information, such as the final SQL from the report framework, and generate the corresponding Crystal Reports. CrystalReportDataBean gets the final SQL statement from the Report Control Center, and then executes the query in the database. You get the result set in the JSP, which was used to display the Crystal Report, and you set it as a new data source for the current report. The tools framework then shows the Crystal Report in WebSphere Commerce Accelerator.

1 of 10 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, Rational
ArticleID=241017
TutorialTitle=Implementing WebSphere Commerce operational reports with Crystal Reports
publish-date=07182007
author1-email=zhoubbin@cn.ibm.com
author1-email-cc=dwu@us.ibm.com
author2-email=dwu@us.ibm.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.