Show TOC

Function documentationEmbed Crystal Reports Locate this document in the navigation structure

 

You can embed a crystal report into an IRPT or JSP page using custom tags. The Crystal Report generated from the Crystal Report Designer is a report (.rpt) file that has to be converted to HTML content for rendering on the web page. Crystal Report Java APIs are used in the implementation classes to achieve this conversion of crystal report content to HTML.

The custom implementation classes must be bundled along with dependency jar files and metadata.xml files. This bundle has to uploaded and deployed using the Custom Report Tags screen .

You have created a crystal report. For details, see Creating a Crystal Report.

Prerequisites

To render custom content on a web page, do the following:

  1. Download Custom Report Tags SDK from SAP MII administration menu (  System Resources   Custom Report Tags  ) and implement the interfaces.

  2. Import crystalreportviewers folder under WEB folder of your project to the Web tab of SAP MII Workbench. To do so, download Crystal Reports Runtime libraries for Java from http://www.businessobjects.com/campaigns/forms/downloads/crystal/eclipse/datasave.asp. Extract the downloaded zip file to fetch the folder crystalreportviewers. The extracted contents also contains the required Crystal Reports dependency jars needed for creating the custom tags bundle.

  3. Implemented the following interfaces:

    Name

    Purpose

    Methods

    Attributes

    ICustomReportTag

    Implement this interface to embed HTML content using the Custom tag.

    For example, implement this interface to embed a crystal report in a IRPT/JSP Page.

    getHTMLContent(Map<String,Object> Hashmap<String, Hashmap<String, String>>)

    Contains the implementation for returning the custom HTML content.

    attributeMap – Contains the attributes and the values for the specified tag.

    childTagParams – Contains the contents of child tags of this particular tag.

    ICustomTagConnection

    Implement this interface to provide content-related information to the parent tag, which embeds content into the IRPT page.

    resolveParameter(String tagName,ICallbackHandler tagSrc,Map<String,Object> attributeMap)

    Contains the implementation for resolving parameters with MII.

    For example, Connection Alias or Credential Alias must be provided as part of the tag and the details of appropriate alias are retrieved. Retrieved values are available for the parent tag to resolve accordingly.

    tagName – Name of the tag for which the parameters are being resolved.

    tagSrc – Source from which the tags are being instantiated by the interface ICallbackHandler.

    attributeMap - Contains the attributes and the user specified values for the tag.

    ICallbackHandler

    Initiate a callback from the custom tags to resolve parameters such as Connection Alias and Credential Alias as specified in the ICustomTagConnection interface.

    callback(String tagName,String paramName,String paramValue)

    This method is invoked at the source side when the custom tag initiates the call for parameter resolving

    tagName - Name of the tag for which the parameters are being resolved.

    paramName – Name of the parameter which has to be resolved at the source side.

    paramValue – Value for the user specified parameter.

Features

You must implement the above interfaces in order to embed a crystal report into an IRPT or JSP file:

To switch connection of the embedded crystal reports at runtime, you have to maintain the connection alias for crystal report connection type in the Connection screen. You can then use this alias in your IRPT page as <crviewer:Connection connectionName = "cr1" /> where cr1 is a connection in SAP MII.

In a JSP page, use the following:

<custag:CustomTag name="crviewer:viewer" path="FlowTQ.rpt">

<custag:ChildCustomTag name="crviewer:viewer" connectionName="cr1”/>

</custag:CustomTag>

The Uniform Resource Identifier (URI) for the prefix “custag“ is defined using <%@ taglib uri="/custag" prefix="custag"%>.

Activities

  1. On the SAP MII Workbench screen, choose Web tab.

  2. Click the secondary mouse button and choose Import.

  3. Select a crystal report file.

    A crystal report file is imported to the SAP MII Workbench.

  4. Create or choose an existing IRPT file.

  5. Enter <crviewer: viewer path=”Report1.rpt”/> in the <body> section of the IRPT page.

    Note Note

    The tag groups, tag name, and the attributes are defined in the metadata.xml, which is uploaded as a ZIP file.

    End of the note.
  6. Choose Execute.

    The report Report1.rpt is embedded in the IRPT page.