SDK sample to retrieve (PDF,CSV) report results using the SDK.

Technote (troubleshooting)


Problem(Abstract)

When calling the execute method using the Cognos SDK if you are trying to retrieve output formats other than (HTML, HTMLFragment, XML) I.E (CSV or PDF) the results must be Base64 decoded.

Java and C#

Resolving the problem

After the execute/run method is called determine what format the execute method was called with. If the execute method was called with CSV or PDF then the result will be base64 encoded.

The following sample code is what has been added to the code to base64 encode the results of the CSV or PDF report.

import org.apache.axis.encoding.Base64;
...
Base64 b64 = new Base64(); // needed to convert PDF or CSV output to binary.
byte binaryOutput[] = null;
...
if (format.equals("PDF") || format.equals("CSV" ))
{
binaryOutput = b64.decode(textOutput); // decode the PDF/CSV output to array of bytes.

Ensure the the Go Sales and Retailers sample package is setup/deployed properly. This sample will execute the following report in Go Sales and Retailers.

/folder[@name='Documentation Report Samples']/report[@name='Add Color']

  1. Extract the attached files and modify the code to use a valid endpoint URL.
  2. Modify the localhost string to use a correct server name.
  3. Ensure that anonymous logon in Cognos Configuration is enabled.
  4. Compile and run. The resulting output will be saved on the local file system. c:\reportOutput.<format>
  5. Modify the following line of code if you wish to execute a report in a format other than PDF.

    emf.executeReport(reportPath,"PDF"); // change format to (PDF, CSV, HTML, HTMLFragment, XML)
  6. Re-compile and re-execute.

VERSIONS:
/cognos8Compatible = CRN deprecated methods compatible with Cognos8.1 & 8.2, NOT 8.3
/cognos8 = Cognos 8.1 and Cognos 8.2
/cognos10_1 = Cognos 10.1
/cognos10_2 = Cognos 10.2

Related information

TN 1344773 - Saving Excel report outputs run interactiv

Historical Number

1003319

Rate this page:

(0 users)Average rating

Document information


More support for:

Cognos Business Intelligence
Software Development Kit

Software version:

8.3, 8.4, 8.4.1, 10.1, 10.1.1, 10.2

Operating system(s):

AIX, HP Itanium, HP-UX, Linux, Solaris, Windows

Reference #:

1343829

Modified date:

2011-01-04

Translate my page

Machine Translation

Content navigation