Posts Tagged Cognos API
Cognos and Active Server Pages (ASP) working together
Posted by Scott Andrews in Cognos on March 9, 2011
Sometimes you just need two technologies to talk to each other. This article will describe how easy it is to make your Cognos reports call Active Server Pages and your Active Server Pages to call Cognos reports.
How to reference ASP objects in Cognos
This is really very easy. In Cognos Report Studio, drop an HTML Item into your report. Then add code to this HTML Item similar to the following:
<iframe
src =”/myaspdir/myaspcode.asp”
height=”100″
width=”100%”
align=”right”
frameborder=”0″
scrolling=”no”>
</iframe>
How to reference Cognos Reports with ASPs
In order to do this, you must make an HTTP reference to the Cognos API. This is similar to how Cognos Connection calls and interacts with Cognos Reports. The line of code you see in your web browser every time you run a Cognos report is such an API call.
The reason why these API calls always look incomprehensible is that they are often very long, and all special characters are translated into hexadecimal characters. All that our example API will do is call the Cognos API to run the report titled “My Report”.
The reference we need to run this report is simply this: /content/folder[@name='My Folder']/report[@name='My Report']
But it must be translated into hexidecimal characters to look like this: %2fcontent%2ffolder%5b%40name%3d%27My%20Folderd%27%5d%2freport%5b%40name%3d%27My%20Report%27%5d&
So our Cognos API call string will be made up of 3 or 4 parts:
Part 1: The API call “http://” & Your Server Id & “/bi84/cgi-bin/cognosisapi.dll”
Part 2: The API command “?b_action=xts.run&m=portal/report-viewer.xts&ui.action=run”
Part 3: The Cognos Report reference “ui.object= “%2fcontent%2ffolder%5b%40name%3d%27My%20Folderd%27%5d%2freport%5b%40name%3d%27My%20Report%27%5d&”
Part 4 (Optional): Any specific report parameters you want to include. Parameters are referred to by name, with a &p_ prefix attached. To assign MyParameter to 1, the string value would be “&p_MyParameter=1
With our string built, we are ready to make the API call. This can be done in the ASP code, like this:
mainFrame.Text = “<iframe style=’width:1000px; height:1000px;’ scrolling=’no’ frameborder=’0′ runat=’server’ src=’” & str_COGNOS_API_CALL & “‘ name=’bottom’ style=’padding:0px; margin:0px;’>”
