Skip to Content
1
Former Member
Apr 16, 2015 at 09:05 PM

Crystal Report Instance with JavaScript Viewer API

1588 Views

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>