Archive for March, 2011

Cognos and Active Server Pages (ASP) working together

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;’>”

Share on LinkedInShare on Twitter+1Share on FacebookAdd to BufferSubmit to StumbleUponShare via email

,

4 Comments

Controlling Log files in Cognos Data Manager

By default, Cognos Data Manager does a good job logging its workflow.  But there are times you may want to alter or control logging differently from the default logging function.

Location

For instance, you may want to log files somewhere other than the default location (which is the Cognos install directory /datamanager/log).  There are 3 ways to modify log file locations, but all are a variation on the system variable DS_LOG_DIR.  You can control the value of DS_LOG_DIR:

  • In Cognos Configuration
  • By assigning a value in a command line:  SET DS_LOG_DIR=”C:\CustomDirectory\CustomLogDirectory”
  • By assigning a value in a Data Manager job call by adding this to the command line (or adding to “Additional Options” in job execution options):  -VDS_LOG_DIR=c:\CustomDirectory\CustomLogDirectory

Note:  You can also control the default location of data files in the same three ways, using the DS_DATA_DIR system variable.

Whichever method you choose will depend on what you are trying to achieve.  If you always want to write log files to the same directory, you could choose the Congos Configuration option.  If you want different job logs to be written to different locations, you could choose the job call option.  In this way it is flexible.

Naming

Also by default, Cognos Data Manager names its log files in the following convention:  Component Type (Build, DimBuild or Job) + Component Name + Unique Run Number.  This allows for a historic sequence of past runs to be maintained.  If you wanted to change this name to something that is the same on every run, you could choose to use the -L switch on the command line.  This will overwrite your previous run but may allow an external process to read the results of a single-named log file.

Adding -LThisJobLog would write all log files to a file called “ThisJobLog”.  There are a few caveats about this option.  It will ignore any setting for the DS_LOG_DIR, including the default.  You will find your log file written in the Cognos bin directory instead.  If you want to assign a location other than the bin directory, you will need to add it to the -L switch value.  Because of this unexpected behaviour, I do not recommend using the -L switch to rename log files but the option does exist if need be.

Share on LinkedInShare on Twitter+1Share on FacebookAdd to BufferSubmit to StumbleUponShare via email

, ,

1 Comment