Vous êtes sur la page 1sur 16

Best Practices for Cognos Report Studio

Introduction: In this document few best practices and some of the problems faced with their solution are explained for Cognos Report Studio. Here, explanation is given with the help of one scenario. The scenario is: - one report page is designed which has many query items (list, chart, crosstab etc) - all query items in the report page show the information related to one team at a time, like team members, team status, team projects etc. - same report page is being used for a number of teams and team name is being chosen using prompt at runtime. Best Practices:

1. If any query item in report-page has the information from different database tables, then need to set the following options while creating package. Open the project in Cognos Framework Manager Project -> Edit Governors

Otherwise it will give error for cross joins between query subjects as:

Modify the settings, save and republish the package. It will solve the problem. 2. If in one report page, need to display many query-items like lists, charts, crosstabs etc and these query items are dependent on each other like all query items display information for the same team then use of master-detail relationship is recommended. Because using this relationship, usage of different filters and conditions can be avoided for each query item i.e. it reduces complexity. Master-detail relationship allows two separate queries and objects linked by a common key. To do this, need to set a query for the page which would be considered as master for other objects.

How to use Master-Detail Relationship: For your report, choose Page as:

Then, choose query which you want to make as master for all objects.

Choose any other query-item say list and click on Master-Detail Relationship:

Create a new link and click on OK.

It creates a Master-Detail Relationship in between two objects.

3. In the report page, we are using a number of objects like lists, tables, prompt etc. If we do not want to display any of the query items like prompt on report-page after execution, then need to set property to hide it. How to hide a query item from a report-page during execution: There are two ways to do this. In the properties pane of the query-item, set BoxType as None OR set Visible as false Out of these to set visible property is recommended because it does not affect formatting of other query items. 4. If we want to generate a pdf report of number of reports i.e. a pdf report which has all team reports listed in prompt, then it can be done using Page-Set technique. In this example, team ID is used to connect all report pages.

How to use Page Set Technique: Open Page Explorer-> Report Pages. Then insert Page set as:

Drag your report page under Detail Pages as shown:

Select a query for page set as:

Select Grouping and Sorting from properties pane.

Choose the common data item from the selected query as:

Finally, you will get this:

How to generate a pdf report: Save report and in the explorer page click on set properties of the report as:

Choose Report tab on Set Properties page:

Change the setting as shown:

Click OK. Run the report. On execution, it will open a pdf file which will contain all teams report in it. 5. Use Parameters to generate dynamic reports. By using parameters, reports become less complex and many static conditions like date dependency can be avoided. Parameters are created using prompt query-items.

How to use parameters: If we insert any prompt in the report, it opens a wizard as:

Using this we can create a new parameter and can be used any existing parameter for the inserted prompt object.

On clicking next, it asks for a package item. Package item is the data item which we want to choose at run time and queries will take that value to display information on report.

Once the parameters are created, it can be used in queries, filters, slicer etc. In Cognos queries, parameter is referred as ?<ParamName>? for eg; ?Parameter1? Parameter usage in filters:

6. If we have bar chart in the report-page, then following information will explain how to manipulate with colors in a bar-chart. If we want same color in all bars, then set Series Color as Match.

If we want different color in all bars, set Series Color as Do Not Match and choose Palette.

10

Click in Properties pane to define Palette.

You can define the sequence of colors as per your choice. Colors can be moved up and down using arrows shown in snapshot. Bars in chart will be shown in same color sequence. If you want a palette color more than once in the chart or you want a new color in the palette, then need to add color which is required.

11

Click on New Palette Entry -> Color, it will add as black color palette.

12

Click on black color box in right side panel Color and choose color which is required. It will add a new color or add the existing color second time in this palette. 7. If the database (source of cognos reports) gets changed at later stage like adding a table, deleting a column in a table etc, then needs to update package accordingly to reflect such database changes in the report. How to reflect database changes in Cognos Reports: If we add a new table/view in DB, open your project in Framework Manager. Run Metadata Wizard for the Data Source.

Select the new table/view for the required schema and import that object. Once imported you will get new table listed under your data source. If you modified one table in database like added/deleted a column then it is not required to import the object (table). Just edit the definition of table.

13

It will open Query Subject definition as:

Click OK. It will update table fields as per the modified table. After updating Data Source, need to re-publish package to reflect the change in Cognos reports.

14

Save the project in Framework Manager. To reflect package changes in existing reports, save and reopen the reports. If a column in table is deleted from DB and the same column is used in the report, it will report error for that. Before continuing the work in report, need to delete that data-item from your reports queries (wherever used). 8. Usage of Cognos reports URL: If the requirement is to incorporate Cognos reports to some UI application, then URL of report should be used. How to get URL of report: Choose Set properties of the report:

Select the URL and modify localhost by machine IP/hostname to access report remotely.
http://<ip address>/cognos8/cgi-bin/cognos.cgi? b_action=cognosViewer&ui.action=view&ui.object=defaultOutput(%2fcontent%2fpackage%5b %40name%3d%27DevOps%27%5d%2freport%5b%40name%3d%27TeamReport %27%5d)&ui.name=TeamReport&ui.format=HTML

This is the URL of report.

15

If report uses one or parameter, it will be prompted to user while running this report. To avoid the prompt, we should use parameterized URL. Parameterized URL is URL of report with the parameter(s) value. How to create Parameterized URL: If your report uses two parameter Param1(say team name) and Param2(say date), URL of report can be written as:
http://<IP ADDRESS> /cognos8/cgi-bin/cognos.cgi? b_action=cognosViewer&ui.action=view&ui.object=defaultOutput(%2fcontent%2fpackage%5b %40name%3d%27DevOps%27%5d%2freport%5b%40name%3d%27TeamReport %27%5d)&ui.name=TeamReport&ui.format=HTML&Param1=Team1&Param2=2010-05-20

If well attach one parameter value with URL, it will ask for Param2 value during execution.

16

Vous aimerez peut-être aussi