18
MII - Crystal Reports Configuration Guide

MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

Page 2: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

2

TABLE OF CONTENTS

INTRODUCTION ............................................................................................................................................... 3

CONFIGURE SAP CRYSTAL REPORTS TO USE CR MII CONNECTOR ..................................................... 4

CREATING CONNECTION TO MII SERVER FROM SAP CRYSTAL REPORTS DESIGNER ...................... 5

CREATING REPORT FROM MII QUERY TEMPLATE .................................................................................... 7

EMBEDDING CRYSTAL REPORT IN MII WEB PAGE ................................................................................. 11

SUPPORTABILITY ......................................................................................................................................... 16

FAQS ............................................................................................................................................................... 17

Page 3: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

3

INTRODUCTION

SAP Crystal Reports is a business intelligence application used to design and generate reports from a wide range of data sources. One of the connectivity methods is JDBC (JNDI). Hence we use this to connect to MII server. MII CR connector is a JDBC connector which exposes MII as datasource. Thus with this one can connect to an MII server and run any query template that is configured on it and generate intuitive and easily understandable reports. The generated reports can be consumed in MII web pages by creating custom tags. This document will lead you through all the steps necessary for the integration of SAP Crystal Reports with SAP MII. It will guide you through the steps for configuring the MII CR connector in SAP Crystal Reports, create connection to MII server, create reports out of MII Query Templates and embed reports in MII web page. The prerequisite for following the below steps is that you have already installed SAP Crystal Reports 2011 FP3.

Page 4: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

4

CONFIGURE SAP CRYSTAL REPORTS TO USE CR MII CONNECTOR

Step 1. Download CR MII Connector from MII Admin portal: Content Development Tools and Archives.

Step 2. Copy the downloaded connector to the following location in CR installation directory:

<CR_Install_Dir>\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java\lib\external

Step 3. Edit classpath element of CRConfig.xml (<CR_Install_Dir>\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java) to include the location of the downloaded jar file as shown:

Here <CR_Install_Dir> is the SAP Crystal Reports installation directory.

Page 5: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

5

CREATING CONNECTION TO MII SERVER FROM SAP CRYSTAL REPORTS DESIGNER

Start the SAP Crystal Reports designer. Select start a new report Blank Report. The Database Expert dialog opens up.

Double click JDBC (JNDI) under Create New Connection node, the connection wizard opens up:

Page 6: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

6

Enter the following details:

1. Connection URL: In case of http MII server: jdbc:sapxmii://<host>:<http-port>/ For https MII server: jdbc:sapxmii://<host>:<https-port>/?ssl=true You also need to import MII server certificate into the keystore of the jvm where Crystal Reports is running from the command prompt. For this you first need to export the server certificate from a browser. Once you have the certificate stored in some location say: <local_drive>\MII\Certificates\MII_Server.cer, you can use the following command to import it into the keystore: <CR_Install_Dir>\\"SAP BusinessObjects"\\"SAP BusinessObjects Enterprise XI 4.0"\\win32_x86\\jdk\\jre6\\bin\\keytool.exe -import -file <local_drive>\MII\Certificates\MII_Server.cer -keystore <CR_Install_Dir>\\"SAP BusinessObjects"\\"SAP BusinessObjects Enterprise XI 4.0"\\win32_x86\\jdk\\jre6\\lib\\security\\cacerts -alias aliasname Restart SAP Crystal Reports designer if open during the above step to reflect the keystore changes.

2. Database Classname: com.sap.xmii.bobj.crystal.jdbc.CRMIIConnector Click Next, and enter the credentials for the server.

The field Database is optional. Click on Finish to complete creating the connection. On successful connection, it lists down the projects on the MII server.

Page 7: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

7

CREATING REPORT FROM MII QUERY TEMPLATE

1. Start Crystal Reports 2011 designer, select start a new report Blank Report.

2. Open Database Expert. Under Available Datasources, you will find a node named My Connections,

upon expanding which you will be able to see the connection that you had created in the previous step. On expanding a connection, the projects on that MII server get listed. You can then select a project to find the query templates under it. You can select the query template from which you want to create the report and add it to the selected tables list. Then click OK.

3. The design pane opens up, with the fields explorer view on the right. You can expand the query template to get the fields or columns for the query template. You can drag and drop the required fields into the design pane.

Page 8: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

8

4. To run the report, select Print Preview from view in the tool bar. The query template gets executed and returns data for only those columns or fields that you have chosen.

Page 9: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

9

5. You can also apply filter to the data returned from a query template by creating parameter fields in CR designer and associating it with column field. For this right click on Parameter Fields and select New. Define the parameter by giving it a name, datatype and associating it with a column/field. This new parameter acts as a place holder for column/field.

6. After this you need to associate the parameter created in the previous step to the column field and provide the filter criteria or condition. For this go to Report Select Expert Record

7. Then choose the field with which you want to associate the parameter to.

8. Select the condition by which you want to filter the data.

9. Select the parameter field that you had created from the adjacent drop down and say OK.

10. Now, when you execute the report it will prompt you for the input parameter value as shown below. Enter the values and click OK.

Page 10: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

10

The report will get executed based on the value that has been input and return you the filtered data.

Page 11: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

11

EMBEDDING CRYSTAL REPORT IN MII WEB PAGE

Custom content can be embed into MII web page like irpt or jsp by using custom report tags feature of MII. To render any content on a web page it has to be converted to html content for the browser to parse and render it. This conversion of the content to HTML is done by the custom report tag implementation classes. MII provides a custom report tags sdk which contains interfaces that need to be appropriately implemented to convert the content into HTML. This implementation needs to be zipped with a metadata.xml and other dependency files. This zip file has to uploaded using the custom report tags screen and deployed on the MII server. Once deployed, the custom tag can be used in MII web page to embed the required custom content. Thus by creating custom tags for converting crystal report into HTML content, you can embed the crystal reports created in the previous step or any other existing report in MII web page like irpt or jsp page by using those custom tags. For this you would first have to create custom tag using the custom report tags sdk that can be downloaded from the MII admin portal’s Custom Report Tags screen under System Resources.

Once you have downloaded the custom report tags sdk that contains interfaces to be implemented for rendering custom content in the web page. In this case the custom content is the crystal report. The user has to implement the custom report tags by using Crystal Report for Java APIs for rendering the report as html content that can be rendered on the web page. Steps

1. Download Custom Report Tags sdk from MII admin portal: System Resources Custom Report Tags.

2. Download CR for Java Runtime Libraries (API) from http://www.businessobjects.com/campaigns/forms/downloads/crystal/eclipse/datasave.asp This is a zip file containing the necessary jar files which need to be included in the build path.

3. Create a java project and include Custom Report Tags sdk zip in the build path.

4. Create a class (e.g CrystalReportViewer) by implementing ICustomReportTag

5. Implement the method String getHTMLContent(Map<String,Object> attributeMap) to return the crystal report as an HTML string.

6. Bundle this project into a zip with metadata.xml that defines the custom tags to be used in the web page.

7. Bundle the zip file from step 6 along with other CR dependency jars into another zip file.

8. Upload the zip file from step 7 using the Custom Report Tags screen of MII admin portal.

Page 12: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

12

9. The zip file from step 2 contains a folder named crystalreportviewers. Import this folder under the WEB folder of your project under the Web tab of the workbench.

10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab of the workbench.

11. Create a web page (irpt/jsp) under the WEB folder of your project under the Web tab of the workbench. You can use the deployed custom tags in the web page as shown: In the body section of IRPT page add: <tag_prefix:tag_name path = “miireport.rpt” />

In jsp page add the taglib declaration given below: <%@ taglib uri="/custag" prefix="custag"%>

And in the body section add: <custag:CustomTag name="tag_prefix:tag_name" path="miireport.rpt" />

12. Publish the contents in the WEB folder and run the web page using the test button.

You can use the below code snippet to perform step 5: <listing 1> public String getHTMLContent(Map<String,Object> attributeMap){

String reportName = (String)attributeMap.get("path");

HttpServletRequest request =

(HttpServletRequest)attributeMap.get("request");

HttpServletResponse response =

(HttpServletResponse)attributeMap.get("response");

ServletContext servletContext =

request.getSession().getServletContext();

ReportClientDocument clientDoc =

new ReportClientDocument();

clientDoc.setReportAppServer

(ReportClientDocument.inprocConnectionString);

clientDoc.open

(reportName, OpenReportOptions._openAsReadOnly);

Object reportSource =

clienDoc.getReportSource();

com.crystaldecisions.report.web.viewer.CrystalReportViewer

crystalReportPageViewer = new

com.crystaldecisions.report.web.viewer.CrystalReportViewer();

crystalReportPageViewer. setReportSource(reportSource);

String crAsHtmlContent =

crystalReportPageViewer.getHtmlContent(request, response, servletContext);

return crAsHtmlContent;

}

A brief explanation of the above code:

The parameter attributeMap holds various objects such as path(report path), request, response, connectionName and connectionAlias. So, as a first step, we get each of the objects from the map. We then create an object of ReportClientDocument and then call the setReportAppServer method with the parameter ReportClientDocument.inprocConnectionString. Then we call the open method. Then call getReportSource method on clientDoc object. We then create an object of CrystalReportViewer. Then call the setReportSource method with the object that getReportSource had returned. And finally call getHtmlContent method of crystalReportPageViewer object and return the value returned by this call. Once we are done with the implementation we need to bundle this up along with the metadata.xml that defines the tags, their attributes, the implementation class names and the dependencies. The metadata.xml contains the metadata for the tag i.e. details like the prefix for the tag, tag name, name of the implementation class for the tag, the attribute names and whether they are required or optional, the dependencies for the tag implementation.

Page 13: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

13

A suitable usecase for an implementation could be where a user wants to control various Crystal Report parameters like hasPrintButton, hasRefreshButton, hasLogo etc through custom tag attributes. The user can implement the interface in the sdk and using CR for Java APIs set the required parameters based on user input for the tag attribute. For e.g consider the custom tag usage as shown below in a web page: <prefix: tagname path=”report.rpt” hasLogo=”true”/> In the above line, the value of the attribute hasLogo can be used to control whether or not the logo has to be shown as shown below:

Object hasLogo = attributeMap.get("hasLogo");

boolean bhasLogo = true;

if( hasLogo != null) {

bhasLogo =

Boolean.parseBoolean(hasLogo.toString());

}

com.crystaldecisions.report.web.viewer.CrystalReportViewer

crystalReportPageViewer = new

com.crystaldecisions.report.web.viewer.CrystalReportViewer();

crystalReportPageViewer.setHasLogo(bhasLogo);

Note: Zip containing sample code can be found at the link: http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/40a81eed-2457-3010-49aa-e834cd0aa5d6 The structure is as shown:

Please check the sample metadata.xml file for reference.

A basic implementation “BaiscCRViewer.java” of the ICustomReportTag based on the code snippet given in listing 1 is provided. This basic version takes report name as parameter and has implementation to convert CR into HTML to be rendered in the MII web page.

Page 14: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

14

For all basic use cases of embedding CR within a web page, users can use this implementation. However in case you want to do something specific with the report like manipulate some report features using report parameters then it can be done by appropriately changing the implementation. An enhanced version of the implementation of ICustomReportTag and ICustomTagConnection with Credential resolution from MII and Connection switching i.e. “EnhancedCRViewer.java” and “CrystalReportConnection.java” is also provided. With the above example, you can provide the credential alias for the MII server and and thus you won’t be prompted for server credentials upon running the report. Similarly you can also execute a report configured against one MII server to point to a query template on another MII server provided the name of the query template and datatypes of its tags/fields are compatible and you have maintained a connection of type CR for the MII server to which you want to connect to using MII Connections screen.

The JDBC connection properties as shown below need to be maintained while creating a connection type CR for the MII server to which you want to switch to:

Property Name Property Value

Connection URL jdbc:sapxmii://<MII-server>:<MII-port>/

Database Class Name com.sap.xmii.bobj.crystal.jdbc.CRMIIConnector

JDBC Connection String !com.sap.xmii.bobj.crystal.jdbc.CRMIIConnector!jdbc:sapxmii://<MII-server>:<MII-port>/!user={userid}!password={password}

Server Type JDBC (JNDI)

Page 15: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

15

Database Type JDBC

Use JDBC True

Database DLL crdb_jdbc.dll To achieve the above credential and connection resolution you need to use your tags to pass connectioName and credentialAlias attribute values as shown below: In the body section of IRPT page add: <tag_prefix:tag_name1 path=" miireport.rpt">

<tag_prefix:tag_name2 connectionName = “connAlias" credentialAlias = "credAlias"

/>

</tag_prefix:tag_name1>

tag_name1 and tag_name2 are 2 custom tags. tag_name1 is the implementation for ICustomReportTag and tag_name2 for ICustomTagConnection. tag_name2 is nested within tag_name1 and provides a call-back to MII that performs the resolution of the credential alias and connection alias. In jsp page add the taglib declaration given below: <%@ taglib uri="/custag" prefix="custag"%>

And in the body section add: <custag:CustomTag name="tag_prefix:tag_name" path="miireport.rpt" />

<custag:ChildCustomTag name=" tag_prefix:tag_name" connectionName=" connAlias"

credentialAlias = "credAlias"/>

</custag:CustomTag>

(However, in case of jsp you can achieve it by just implementing ICustomReportTag. The CustomTag and ChildCustomTag take care of handling the implementation for resolution. A sample custom tag implementation bundle “CR_customtags.zip” that can be used for rendering SAP Crystal Reports in MII web page is provided as part of this documentation. (The custom tag implementation classes can be located within ViewerTag.zip) The sample web pages that can be used with the above implementation can be found in the zip named “MII-web files.zip”. Refer the README.txt for the steps to be followed. On executing the web pages the MII query template gets executed and the result is rendered in the Crystal Reports embed within the web page as show below:

Page 16: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

16

SUPPORTABILITY

List of functions that are supported

1. The JDBC connector is Read-only: Only “Select” query is supported 2. Field alias is supported

List of functions that are not supported

1. Cursors 2. JOINS 3. Configuration of MII query parameters in Crystal reports

Page 17: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

MII - Crystal Reports Configuration Guide

17

FAQS

1. I am unable to import server certificate into the keystore of Crystal Report’s JVM. Ans. The CR installation might not come with a keytool exe. Check if the following location has the exe:

<CR_Install_Dir>\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\jdk\jre6\bin

2. I have downloaded the connector and copied it to the specified location in CR Installation directory and made appropriate changes in the CRConfig.xml. But when I try creating a new connection to an MII server, I get an error: Server certificate not found. I have downloaded and imported server certificate into Crystal Report’s JVM.

Ans. You would have to restart Crystal Reports designer application after importing the server certificate for the change to take effect.

3. I get an error as shown below on expanding Create New Connections JDBC (JNDI):

Ans. This error could arise due to the following reasons. Hence check the following to resolve the issue:

1. If you get this error the first time you are accessing the designer, you could check if the following location in your CR installation directory has the java.exe file: <CR_Install_Dir>\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\jdk\jre6\bin In case it is not present, copy java.exe (from a 32-bit java installation)

2. In case Crystal Reports didn’t close properly the previous time you used it, a java process may still be running in the back ground and may result in this error when you start designer again. Check the Task Manager to check if you have such a process and end it.

3. If both the above solutions do not help, then revert the changes in CRConfig.xml and replace java.exe at the location mentioned in <1> and try running the designer again.

4. If none of this helps, please raise a ticket with CR team.

4. I have created, uploaded and deployed the custom tag bundle. I have imported a report file in workbench and created an irpt page. I am using the deployed custom tag in the page as shown: <prefix: tagname path=”report.rpt” /> The report however doesn’t come up in the web page.

Ans. Ensure that you have imported crystalreportviewers folder directly under the WEB folder of your project under the Web tab. This folder is present in the CR for Java Runtime Libraries (API) that is downloaded from http://www.businessobjects.com/campaigns/forms/downloads/crystal/eclipse/datasave.asp

Page 18: MII - Crystal Reports Configuration Guide Crystal...10. Import the crystal report that you want to embed in the web page also under the WEB folder of your project under the Web tab

© 2013 SAP AG. All rights reserved.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, SAP HANA, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects is an SAP company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase Inc. Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are registered trademarks of Crossgate AG in Germany and other countries. Crossgate is an SAP company.

All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

www.sap.com