on 04-16-2015 10:05 PM
I was able to implement a sample Crystal Reports Viewer using the JavaScript API (http://help.sap.com/businessobject/product_guides/sbo41/en/sbo41_cr_js_api_en.pdf).
However, I am not sure how to open a report instance within this viewer. When I use the report ID itself, report shows up with relevant login and report parameters prompts. But when I use the report instance ID, I keep getting an error (CRWEB00000119). This report instance has been successfully generated and can be viewed through CMC and Launch Pad. I have also tried a couple of reports, one with a RPT output format and another one with Excel output format but they both result in the same error.
Is it even possible to display report instance through this API? I see a class and a method in this API (SAP.CR.Parameter and addvalue()) which allows someone to pass parameters to the report. In my case since instance has already been generated, I don't want to have to pass the parameters again and execute the report before displaying it. I am looking for a similar functionality that OpenDocument offers to view a report instance.
Any pointers will be helpful.
Thanks.
Adnan
Sample Code:
<head>
<script src="http://<hidden servername:port>/clientapi/CR/ViewerSeed.js"></script>
<script type="text/javascript">
var token = null;
function init() {
token = "<hidden token>";
SAP.CR.Viewer.create("crystalViewer", 'viewerContainer1', onViewerInit, onViewerFailure);
}
function onViewerInit (viewerInstance) {
viewerInstance.setReportSource('<instance id>', token);
}
function onViewerFailure(instance, error){
alert(error);
}
</script>
<style>
.viewerStyle
{
position : absolute;
left : 1.5%;
top : 0.5%;
width : 100%;
height : 100%;
}
</style>
</head>
<body onload="init()">
<div id="viewerContainer1" class = "viewerStyle"></div>
</body>
An update here, I am able to view instances that have an RPT format. I cannot seem to view Excel or PDF output formatted instances. Following is the stack trace I am receiving:
2015-04-17 08:28:00
com.businessobjects.report.web.shared.WebReportingException: The viewer could not process an event. Internal error. Please contact your system administrator. [] ---- Error code:0 [CRWEB00000119]
at com.businessobjects.report.web.shared.WebReportingException.throwWebReportingException(WebReportingException.java:71)
at com.businessobjects.report.web.component.ViewerContainer.processEvents(ViewerContainer.java:1439)
at com.businessobjects.report.web.WorkflowController.doEventProcessing(WorkflowController.java:353)
at com.businessobjects.report.web.WorkflowController.doLifecycle(WorkflowController.java:255)
at com.businessobjects.report.web.WorkflowController.doAsyncLifecycle(WorkflowController.java:106)
at com.crystaldecisions.report.web.viewer.CrystalReportViewerUpdater._processHttpRequest(CrystalReportViewerUpdater.java:61)
at com.crystaldecisions.report.web.ServerControl.processHttpRequest(ServerControl.java:345)
at com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet.doUpdate(CrystalReportViewerServlet.java:206)
at com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet.doPost(CrystalReportViewerServlet.java:194)
at com.businessobjects.report.web.remote.CRVRemoteServlet.doPost(CRVRemoteServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:761)
Caused by: com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Internal error. Please contact your system administrator.---- Error code:-2147215357 [] Error code name:internal
at com.crystaldecisions.sdk.occa.report.lib.ReportSDKException.throwReportSDKException(ReportSDKException.java:120)
at com.crystaldecisions.sdk.occa.managedreports.ps.internal.SendRequestHelper.sendRequest(SendRequestHelper.java:141)
at com.crystaldecisions.sdk.occa.managedreports.ps.internal.CacheReportSource.sendRequest(CacheReportSource.java:1796)
at com.crystaldecisions.sdk.occa.managedreports.ps.internal.CacheReportSource.getPage(CacheReportSource.java:1283)
at com.businessobjects.report.web.event.PageListener.renderContentLocally(PageListener.java:377)
at com.businessobjects.report.web.event.PageListener.getPage(PageListener.java:178)
at com.businessobjects.report.web.event.PageListener.updatePage(PageListener.java:120)
at com.businessobjects.report.web.event.UpdatePageEvent.processListener(UpdatePageEvent.java:47)
at com.businessobjects.report.web.event.ViewerBroadcaster.broadCastEvent(ViewerBroadcaster.java:136)
at com.businessobjects.report.web.event.ViewerBroadcaster.broadcast(ViewerBroadcaster.java:110)
at com.businessobjects.report.web.event.EventQueue.processEvents(EventQueue.java:53)
at com.businessobjects.report.web.component.ViewerContainer.processEvents(ViewerContainer.java:1426)
... 25 more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot open excel and pdf format files in the viewer. Viewer is a component to open crystal report format files.
You can directly download the pdf/excel instances. Below is an example I can think of.
=================================================
// Query the pdf instance
// Download PDF document from the Enterprise
if (infoObjects.size() > 0)
{
obj = (IInfoObject)infoObjects.get( 0 );
IPDF pdfPlugin = (IPDF) obj;
//Stream content back to Web browser.
response.reset();
response.setContentType(pdfPlugin.getMimeType());
response.setHeader("Content-disposition", "attachment;filename=test.pdf");
byte[] bytes = pdfPlugin.getContent();
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(bytes);
outputStream.close();
====================================================
Thanks,
Prithvi
Hi Adnan,
This post is very helpful to me.
I have been searching around for a CR - PDF in JavaScript solution but only found luck in .NET solutions.
May I please ask if your scenario is similar to mine:
- Back-end a .rpt ready crystal report file (I.E. CustomerInvoice.rpt)
- Browser which captures input or pull data from Database to fill in the parameters in the .rpt
- Allow users to download PDF format immediately
If so, may I add on:
You mentioned -
<script src="http://<hidden servername:port>/clientapi/CR/ViewerSeed.js"></script>
May I ask what did you install to have that url working? Apparently it isn't working on my side (following the developer's guide). Which is one workaround, I reference the entire folder in the SAP Business Objects in local drive (C://), to an IIS. But still no luck.
Did you install all of these from SMP? (Part 1 - 5)
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jacob,
I didn't have to install anything on the client side (my development machine) to be able to invoke the URL http://<hidden servername:port>/clientapi/CR/ViewerSeed.js
I am not sure what errors you are getting on your end.
Regarding the scenario, I wanted to be able to open a report instance in RPT output format and Excel/PDF format. It turns out that only RPT format can be opened via the JavaScript API. I got a confirmation from SAP on this.
You have two options if you need PDF output.
Regards,
Adnan
Hi Adnan,
Thank you so much for getting back to me with detailed response.
You're right about the latter part.
Just to add on to your comment (for those who are searching for this resolution):
1. In order to use ViewerSeed.js, you're required to install BIP server.
2. In SMP, it's the 64bit Version of BIP Server.
3. After setting up the server, use the BIPRWS (RESTful Web Services) to call & retrieve a token: this is to authenticate the user is a valid one.
4. Use the token to use ViewerSeed.js as part to create a CrystalReportViewer component in your Web Application.
Taking it from there,
- CrystalReportViewer (CRV) only creates a container to hold Crystal Reports in Web Application / Application to view the instance of it.
- Prithviraj Shekhawat mentioned the right way to export it as a PDF or any other format from CRV instance it self.
Hope these helps future viewers.
Thank you.
Cheers,
Jacob
Hi Jacob
Can I use crystal report and calling it through SAPUI5 application(javascript web based app)? What is the type of output will be seen by user?
What do i need for implement this thing?
My team still confused which reporting tools we should buy for our project..
Really appreciate your help.
Thanks
Yoppie A.
Yes you can render it within SAPUI5 control (HTML).
For the output, depends on your processing, you can output it either a crviewer or a PDF.
I wouldn't recommend BIP (Business Intelligence Platform) for your team to purchase (licenses too expensive I supposed).
You can check out and download the All-in-one zip file. Once unpacked, you can use it already. You can refer to the CR help in that Eclipse. If you prefer more of a .NET environment, I'm sure there are other reporting solutions that are better to manage CR in .NET.
Hope it paints a better picture for you.
Cheers.
Regards,
Jacob Tan
Hi Jacob,
var oHtml = new sap.ui.core.HTML({
content: '<iframe id="myiframe" width="'+defaultWidth+'" height="'+defaultHeight+'">No iframe support</iframe>'
});
Does it mean we can embed crystal reports's output to Browser?
How about printing the report?
Thank you for your answer, really appreciate that. Since we are working on big project and my client need it developed in rapid methodology. I think it's necessary to use reporting tools. Should we install crystal server on our hana machine?
Thank you
Yoppie A.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.