Skip to Content

>

+I work for SAP Business Objects in Technical Customer Assurance.  My speciality is the Software Development Kits (SDKs) that we provide with our Business Intelligence products – BusinessObjects Enterprise, Web Intelligence, Desktop Intelligence, Crystal Reports and Crystal Xcelsius.  </p><p>In my blog, I discuss subjects that I personally find interesting – little known or not-well-documented corners of the SDK, new functionality or new SDKs, or interesting issues that I’ve come across in a SAP Incident or SAP Developer Network forums.  </p><p>You’re more than welcome to suggest any topic (SAP Business Objects SDK related, of course…) that you’d like me to discuss – I have a dozen or so items on my blog to-do list, but I’m always on the hunt for anything interesting with our SDKs.+   </p>

Crystal Reports for Eclipse Version 2 is out!

If you’re a Java Developer looking to integrate reporting into your web or desktop application, I recommend going+ immediately+ to the 

Crystal Reports for Eclipse and Java

section of the Business Objects Community  (https://www.sdn.sap.com/irj/boc) portal to download your copy and check it out. 

I’ve been supporting the Java Reporting Component (JRC) SDK – the 100% pure Java Crystal Reports engine and viewer – since Version 10, and each new version of the JRC has brought tremendous gains in performance, functionality and features.

CR4E Version 2 is no different – even more so, since the gains in functionality are the greatest ever.  I’ve been working with a pre-release copy since last Quarter, and I have to say I’m pretty darn impressed.  The bar’s been raised pretty high for Business Intelligence products in the Java development sphere.

This may sound like hype – but please do read on. In this blog, I’ll describe what I find interesting – specifically the new SDKs that come with this version.  After reading,  download a copy – it’s still free! – and see for yourself.

Crystal Reports 2008 Support

The Crystal Reports 2008 product shipped with the

.NET reporting components

– CR.NET and inproc RAS .NET SDKs. The Java Reporting Component had been split off to be part of Crystal Reports for Eclipse – but Version 1 supported reports only up to XI Release 2.

With CR4Ev2, we now have a Java reporting component conterpart to .NET that fully supports Crystal Reports 2008 features such as Crystal Reports Xcelsius / Adobe Flash embedding, interactive parameters and sorting, cross-tab improvements, and a lot lot more  (http://www.sap.com/solutions/sapbusinessobjects/sme/reporting/crystalreports/featuresfunctions/index.epx).

Let me highlight two of the cool new 2008 features here:

Crystal Xcelsius / Adobe Flash embedding

With Crystal Reports 2008 and Crystal Xcelsius  (https://www.sdn.sap.com/irj/boc/xcelsius), you can design a report with data-bound graphical  Flash controls, for a more expressive display of information and a more interactive experience for your clients.

Here’s a screenshot of the CR4E SDK web application displaying a Crystal Report with embedded Xcelsius:

CR4Ev2 Web App Displaying CR2008 Report with Embedded Xcelsius

World Sales Report with Crystal Xcelsius

The “Sales Rep” names are ‘clickable’ – by clicking on a name, the charts in the Xcelsius component will instantly update to show data for that particular rep.

Interactive Parameters

With 2008 and CR4Ev2 web viewer, you no longer need to re-run a report to set new parameter field values.  Rather, the viewer includes an interactive parameter field selection panel to the right of the report display.  You can modify the parameter field values interactively while viewing the report.  Furthermore, by defining parametrized “Saved-Data Selection Formulas”, updating parameter values need not re-connection to the database.  Rather, filtering will be done on the data saved in the report during previous refresh.

The UI for the parameter field selection dialog box is also slick – here’s a screenshot:

CR4Ev2 Web App Displaying CR2008 Report with Interactive Parameter

image

The field selection box uses Adobe Flash (Flash 9 installation is required on the client computer) for a more immersive UI experience.

Report Export Format Enhancements

I’ll say that the most frequent enhancement requests for the JRC I’ve received while working in tech support concern export formats:  (1) Excel export, and (2) font embedding in PDF export.  CR4Ev2 provide both.

Excel (data-only) export

Excel (data-only) export is available either through the report viewer (via export button) or through code.  Here’s a code snippet that exports Excel (data-only) via a JSP page:

JSP page exporting Excel data-only

<br /><textarea cols="78" rows="8"><%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
    com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
    com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
    com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat,
    java.io.ByteArrayInputStream"
%>

<%

String reportPath;

Object reportSource;

ReportClientDocument reportClientDocument;

ByteArrayInputStream byteArrayInputStream;

byte[] byteArray;

int bytesRead;

reportPath = request.getParameter(“report_path”);

/*

  • Instantiate ReportClientDocument and specify the Java Print Engine

  • as the report processor.  Open a rpt file and export to Excel.  Stream

  • Excel back to web browser.

*/

reportClientDocument = new ReportClientDocument();

reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);

reportClientDocument.open(reportPath, OpenReportOptions._openAsReadOnly);

reportSource = reportClientDocument.getReportSource();

session.setAttribute(“ReportSource”, reportSource);

byteArrayInputStream = (ByteArrayInputStream) reportClientDocument

        .getPrintOutputController().export(ReportExportFormat.recordToMSExcel);

response.reset();

response.setHeader(“Content-disposition”, “inline;filename=crreport.xls”);

response.setContentType(“application/excel”);

byteArray = new byte[1024];

while((bytesRead = byteArrayInputStream.read(byteArray)) != -1) {

     response.getOutputStream().write(byteArray, 0, bytesRead);     

}

response.getOutputStream().flush();

response.getOutputStream().close();

reportClientDocument.close();

%>

The format type is ‘ReportExportFormat.recordToMSExcel’.

PDF export with font subsetting

PDF exports from previous versions of the Java Reporting Component used font indexing, where the PDF file holds the font family/name/style/size info, but not the font glyphs (i.e., the font images).  This led to two limitations (1) not all characters – especially non Western European characters – could not be expressed using the ANSI character encoding used for the indexing, and (2) the fonts had to be available on the machine where the PDF file was viewed – particularly troublesome when specialized and/or licensed fonts are used.

With font subsetting  (http://www.adobe.com/products/adobemag/archive/pdfs/98wihttp.pdf), the glyphs of all chars used in the PDF are stored in the file itself and used to draw the chars when the PDF is viewed.  Fonts no longer need to be available on the machine where the PDF is viewed, and all Unicode characters are expressible.  CR4Ev2 puts the “Portable” back in “Portable Document Format”.

Here’s a code snippet for exporting to PDF programmatically:

JSP page exporting PDF

<br /><textarea cols="78" rows="8"><%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
    com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
    com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
    com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat,
    java.io.ByteArrayInputStream"
%>

<%

String reportPath;

Object reportSource;

ReportClientDocument reportClientDocument;

ByteArrayInputStream byteArrayInputStream;

byte[] byteArray;

int bytesRead;

reportPath = request.getParameter(“report_path”);

/*

  • Instantiate ReportClientDocument and specify the Java Print Engine as the report processor.

  • Open a rpt file and export to PDF.  Stream PDF back to web browser.

*/

reportClientDocument = new ReportClientDocument();

reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);

reportClientDocument.open(reportPath, OpenReportOptions._openAsReadOnly);

reportSource = reportClientDocument.getReportSource();

session.setAttribute(“ReportSource”, reportSource);

byteArrayInputStream = (ByteArrayInputStream) reportClientDocument

        .getPrintOutputController().export(ReportExportFormat.PDF);

response.reset();

response.setHeader(“Content-disposition”, “inline;filename=crreport.pdf”);

response.setContentType(“application/pdf”);

byteArray = new byte[1024];

while((bytesRead = byteArrayInputStream.read(byteArray)) != -1) {

     response.getOutputStream().write(byteArray, 0, bytesRead);     

}

response.getOutputStream().flush();

response.getOutputStream().close();

reportClientDocument.close();

%>

Since the font glyphs are included, expect the PDF file size to be bigger than in previous versions – but this is a small price to pay for il8n support.

New SDKs 

What I find especially exciting are the two new SDKs introduced with CR4Ev2: Crystal Reports Java and Crystal Reports Designer Extension Points.

Le JRC est mort.  Vive le CRJ! 

Let me officially announce that the Java Reporting Component is dead.  Ok, so it’s not really dead (it’s still fully supported), but it’s deprecated as of this version.  But no need to mourn, since it’s been replaced by something much, much better:  the Crystal Reports Java (CRJ) SDK.

If you’re an old Crystal Reports hand, or current with BusinessObjects Enterprise or Crystal Reports Server, you’re likely familiar with the Report Application Server (RAS) SDK.  If so, then the CRJ SDK will look very familiar – the APIs are almost all, with few minor exceptions, the same. 

The 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 are used, but report processing requests are sent to a background in-process Java report engine. 

Where in unmanaged RAS, you’d connect to the RAS server via:

reportClientDocument = new ReportClientDocument();<br />reportClientDocument.setReportAppServer(“<hostname>:<port>”);

in CRJ you’d specify a special String value for the ReportAppServer property:

reportClientDocument = new ReportClientDocument();<br />reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);

to configure the backend report engine. Not much other code changes are required to migrate from RAS to CRJ SDK.

Migrating from JRC to CRJ is also straightforward. Class and method names mostly remain the same, and only the package name need be changed: instead of using JRC classes in the com.crystaldecisions.reports.sdk package, use the equivalent CRJ classes in the com.crystaldecisions.sdk.occa.report.application package.  Since the JRC shared many classes with the RAS SDK, and the JRC-specific classes where thin wrappers around RAS classes, there won’t be any fundamental workflow changes required.

Report Creation/Modification API (RCAPI)

A great enhancement of the CRJ over JRC is the introduction of RAS-type report creation and modification capabilities.  With the CRJ, you’ll be able to programmatically modify a report on-the-fly:  create new fields, introduce new data connections and tables, modify images, add lines and boxes, etc.  You can even create reports from scratch.

Anything you can do to a report using the CR4E embedded designer, you can do programmatically – the designer uses the same SDK.

The CRJ RCAPI is inherited from the RAS SDK, and Shawn – one of my colleages – found that most RAS RCAPI code that he looked at translates to CRJ with only very minor modifications.  There’s lots of RAS code out there, back from RAS 9 and Crystal Reports Server Embedded 10, that can now be migrated over to a 100% pure Java solution.

Here’s a sample – RCAPI code to create a new Crystal Report that reports off a XML file:

CRJ SDK code to create a new report off of XML data source

package com.businessobjects.samples;

import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;

import com.crystaldecisions.sdk.occa.report.application.ReportSaveAsOptions;

import com.crystaldecisions.sdk.occa.report.data.ConnectionInfo;

import com.crystaldecisions.sdk.occa.report.data.Table;

import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;

public class CreateXMLReport {

    /*

  • Create Crystal Report with XML connectivity and save to file.

     */

     public static void main(String[] args) throws Exception {

          ReportClientDocument reportClientDocument;

          ConnectionInfo connectionInfo;

          PropertyBag propertyBag;

          Table table;

          reportClientDocument = new ReportClientDocument();

          reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);

          reportClientDocument.newDocument();

          propertyBag = new PropertyBag();

          propertyBag.put(“Local XML File”, “C:

Samples

test_data.xml”);

          propertyBag.put(“Server Name”, “C:

Samples

test_data.xml C:

Samples

test_data.xsd”);

          propertyBag.put(“Server Type”, “XML and Web Services”);

          propertyBag.put(“PreQEServerName”, “C:

Samples

test_data.xml C:

Samples

test_data.xsd”);

          propertyBag.put(“Local Schema File”, “C:

Samples

test_data.xsd”);

          propertyBag.put(“Convert Multivalue to Table”, Boolean.FALSE);

          propertyBag.put(“Database DLL”, “crdb_xml.dll”);

          connectionInfo = new ConnectionInfo();

          connectionInfo.setAttributes(propertyBag);

          table = new Table();

          table.setName(“schema1/People”);

          table.setAlias(“schema1/People”);

          table.setConnectionInfo(connectionInfo);

          reportClientDocument.getDatabaseController().addTable(table, null);

          reportClientDocument.saveAs(“xml_report.rpt”, “C:

“, ReportSaveAsOptions._overwriteExisting);

          reportClientDocument.close();

     }

}

What makes the RCAPI functionality particularly useful is that it’s exposed in the embedded designer via the Designer Extension Points SDK. 

Designer Extension Points SDK 

The new Designer Extension Points SDK exposes the embedded CR4E report designer via the Eclipse IDE plugin framework.  Via this SDK, you can programmatically extend the functionality of the CR4E embedded designer.  You can create custom Crystal Report creation wizards, your own Drag-and-Drop handlers, or even add new tabbed pages to the embedded designer view itself.

Here’s a screenshot of a custom Crystal Report creation Wizard that I wrote running in Eclipse:

CR4Ev2 Designer with Custom Report Creation Wizard

image

With a couple pages of code, I was able to create a Wizard that allows the user to select a Company and report title, that then generates a skeleton report with the corporate logo, title, and report footer text pre-filled. 

With an OEM/Partner license, you can even embed the CR4E designer in your own Eclipse-based Java desktop application, to allow users of your app to create/modify their own reports. 

Web Viewer Enhancements

I’ll briefly cover few of the CrystalReportViewer DHTML viewer enhancements: 

Parameter field selection page improvements

The parameter dialog box itself in the CR4Ev2 web viewer is much improved – it uses Adobe Flash for greater interactivity and more expressive UI:

CR4Ev2 Web Viewer Parameter Dialog Panel

!https://weblogs.sdn.sap.com/weblogs/images/251913699/parameter_prompting.JPG|height=359|alt=image|width=556|src=https://weblogs.sdn.sap.com/weblogs/images/251913699/parameter_prompting.JPG|border=1!</body>

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply