The Cognos SDK occupies a strange position in the Cognos development ecosystem. It gets thrown around as a solution to a number of problems, but a lot of people who work all the time in Report Studio or Framework Manager really don’t know what it is. People working with Cognos usually have a database or business analysis background, not programming, and often are not familiar with the term ‘SDK‘. A lot of the materials on the SDK immediately dive into details without a big-picture overview, so here’s my take on what it is and why you might be interested in it.
‘SDK’ stands for software development kit. It’s a set of code libraries, ie. jars or dlls. The SDK comes in three different programming languages: java, C#, and visual basic. It’s not a studio or plugin or executable program. It’s nothing that you’d use inside the main Cognos applications. It’s code that a programmer can use to write a script or application that talks to a Cognos server.
In general, it’s for administrative purposes rather than writing reports or queries. A few different uses:
- Write your own custom security provider.
- Integrate Cognos into your own application.
- Script out adminstrative tasks.
- Programmatically do just about anything you can do manually in Cognos Administration.
You can automate back ups, installs, permission grants, or whatever. If you’re an OEM provider of Cognos, using the SDK is essential. It will allow you to seamlessly integrate a huge amount of Cognos functionality into your own application. Your users may not even know or care that you’re relying on Cognos for your reports.
How to get started
Get a license (which is expensive, unfortunately), then download the installer from the usual IBM Cognos site. By default, it will be installed into an existing Cognos installation. Under the sdk folder, you’ll see the different versions. I’ve only used the java one and that’s what I’m going to talk about, but the csharp and vb versions should be equivalent in most ways.
A few important things to look at…there is a ‘lib’ folders with jars, which contain the SDK code. You’ll need to include these jars in your app. A lot of small sample applications like ViewCMReports, ReportDelete, and AuthenticationProvider are included. There are also some useful folders containing shared code, like Common and Security. There is a ‘doc’ folder that contains javadoc. This is mostly worthless. The user guide has much better documentation. It’s outside of the sdk folder, in
webcontent\documentation\en\dg_sdk.html. It has good write-ups on how to set up your environment, how to run samples, what you can do, etc.
When you’re ready to start coding, look at a sample for some guidance and build off that. Most applications start by connecting to a running Cognos server, then logging in. The code in
common\crnserver.java handles connection stuff. Feel free to copy it. For authentication, see
Security\Login.java (and copy it, too!).
The quickest way to figure out how to do something is usually going to be finding a relevant sample and copying it. Studying the API is not very useful, unfortunately. Important objects usually have generic property arrays to hold useful information, and instead of well-named, self-documenting methods, you get a lot of ‘setValues’ and ‘adds’. The names of the properties you need don’t seem to be documented anywhere except in the samples.
That said, the code is not particularly hard to deal with and the samples are quite good. It does take some time to get familiar with the API, but the difficulty just depends on what you’re trying to do. Something like automating package deployments is trivial, but writing your own security provider is a lot more challenging. If you need to extend the functionality of Cognos and you have programming resources on your team, the SDK is worth looking at.