cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Instance with JavaScript Viewer API

Former Member
0 Kudos

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>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Prithvi!

We are already using the file download based solution so good to see that was your suggestion as well. Regarding Crystal Reports JavaScript API, I have a ticket with SAP in progress as well and they will likely confirm what you have said above.

Best regards,

Adnan

Answers (1)

Answers (1)

jacobtan89
Explorer
0 Kudos

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)

  1. SBOP BI PLATFORM 4.1 SP05 CLIENT TOOLS WINDOWS (32B)
  2. SBOP BI PLATFORM 4.1 SP05 ENTER .NET SDK RUNTIME WINDOWS
  3. SAP CRYSTAL REPORTS FOR ENTERPRISE 4.1 SP05 WINDOWS (32B)
  4. SBOP BI PLATFORM 4.1 SP05 INTG FOR MS SHAREPOINT WINDOWS 32B
  5. SBOP BI PLATFORM 4.1 SP05 LIVE OFFICE WINDOWS (32B)

Thank you.

Former Member
0 Kudos

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.

  1. Allow user to export to PDF using the export feature of this JavaScript based report viewer
  2. Use the direct file download off of the server as mentioned by Prithviraj above

Regards,

Adnan


jacobtan89
Explorer
0 Kudos

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

yoppie_ariesthio
Participant
0 Kudos

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.

jacobtan89
Explorer
0 Kudos

Hi ,

Yes you can render it within SAPUI5 control (HTML).

  1.     var oHtml = new sap.ui.core.HTML({ 
  2.       content: '<iframe id="myiframe" width="'+defaultWidth+'" height="'+defaultHeight+'">No iframe support</iframe>' 
  3.     }); 

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

yoppie_ariesthio
Participant
0 Kudos

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.

former_member197386
Active Contributor
0 Kudos

Hi Yoopie,

If you have a BusinessObjects BI4 running in your landscape, I can advise you to consider to look at Web Intelligence RESTful API (the leading BI reporting tool).

Regards,

Anthony