Note: This article describes undocumented and officially not supported features of IBM Cognos SDK.
Dealing with a large number Enterprise Information Systems (EIS) may be very challenging especially when you need to integrate systems designed with different concepts and running on different operating systems. Using IBM Cognos SDK you can e.g. automate report output generation and deliver the result in different formats. A widely consumable format is the Comma-Separated Values (CSV) format. The default delimiter used by the IBM Cognos Report Server is the Tab character (\t). This value could be changed by changing the advanced Report Server property RSVP.CSV.DELIMITER. In some cases you may be not able to change this property because it is global, so it will affect all users and all processes running on the Report Server. What should you do when you need to create an application which delivers a report output in CSV format but some legacy EIS require a delimiter that his not the default?
I will show how to use an undocumented feature of the IBM Cognos SDK to solve the problem above.
Please, check out the existing "SDK sample to retrieve (PDF, CSV) reports results using the SDK" from IBM Support Site. We will modify the executeMultipleFormats class defined there. Before we start to modify that code, please, update the reportPath and the dispatcherURL – both defined in the main() method to point to a valid report and to your Dispatcher Service. The solution is based on using FormFieldVar. FormFieldVars is an array of parameters which exist in the HdrSession – a part of BiBusHeader. We need to modify the BiBusHeader instance before executing the report. We have to add a method to access the BiBusHeader. Let us modify the existing getReportService() method and add 2 following methods as below:
We need to modify the quickLogon() method too:
We have added the lines 281-282 where we copy the BIBusHeader from CM service to the ReportService.
Now, let us go to line 59 and refactor the signature of executeReport() method as follows:
We will set the delimiter in the FormFieldVars array. Let us add the following code before line 100, i.e. before calling getReportService(true).run().
Lines 104-106 from the snipped are most important for our topic. We create a FormFieldVar variable with the name:
and its value is set to:
"<root><item name="RSVP.CSV.DELIMITER">" + delimiter + "</item></root>"
In most cases the delimiter is specified using a literal character between the double quote character, e.g. ";", "." but there are 3 special delimiter values: "TAB", "CR", "LF" for \t, \r and \n respectively.
Please, note that the call to getReportService(true) was also changed to getReportService(bibus).
Note that not all advanced server properties can be specified in a FormFieldVar, but it does work with this one.
To complete the sample, please use the outputFileName variable we created during refactoring in all 2 places the files are created, e.g.:
Let us run some tests now. In the main() method I have added 3 calls to the executeReport():
The first call uses the TAB character (\t) as the delimiter, the 2nd uses the semicolon (;) and the 3rd passes the null value, in what case we do not change the default, system-wide delimiter setting.
Please, check your generated files to verify results.