You are on page 1of 18

Problem:

A page breaks occur in HTML Layout when a combination of list (or crosstab) and chart objects are
added to the report page. The "Rows Per Page" in run option (Report Studio), or advanced run option
(Cognos connection) can be increased to a high number to keep all query frames in one page.

This document describes how to set the number of "Rows Per Page" in report with a chart.
Cause
A Rows Per Page property exists in the Properties pane for lists and crosstabs. If you specify a value for
this property, it overrides the same-named run option. This property applies to HTML, PDF, and Excel
outputs. This property does not exist in the Properties pane for charts.
Environment
IBM Cognos 8 BI Report Studio
Resolving the problem
Nest the chart within a dummy list. You can change the Rows Per Page property in the
Properties pane of this list. Make sure that this dummy list returns exactly one record.

Steps:
Create a new blank report
In the Insertable Objects pane, click the toolbox tab.
Insert a list object to the report
Add a data item to the report. Make sure that this query returns exactly one record by using a
filter.
Change the Rows Per Page property in the Properties pane for list.
Insert a table object into the list.
Click the unlock button in the toolbar
Insert a chart object into a table cell. Create the report as usual.
Hide unused columns and column title of the dummy list. Therefor select the column / column
title and set the box type to none.

RQP-DEF-0103 Cross joins are not permitted.
Problem(Abstract)
Sometimes in certain reporting situations, a user will inadvertently create a cross join. A cross join is a
join between two query subjects that do not have any links at the model level (or in some cases at the
database level). This can happen under a wide variety of conditions. For example, in a model, there may
be a table which is standalone because it is a lookup table that is used to create filters when filtering
other query subjects. In this case, when a user attempts to include query items from the lookup table in
a filter on a query subject in the model, a cross join would be created.

The reason Cross Joins are not desirable is because they cause the Cognos 8 server to do query
processing rather than having the database do the query processing (so basically, "Local Processing" is
occurring rather than "Database Processing."
Symptom
RQP-DEF-0103 Cross joins (between query subjects X and Y) are not permitted for the user who has the
identity (XXXXYYYYZZZZ)
Cause
No Relationship between tables at the model level
Resolving the problem
There are a few different ways to circumvent this error:
A. Find a different way to achieve the desired results that does not end up in a cross join.
B. Enable cross joins for the query causing the error.
C. Enable cross joins in the model.
Note that enabling cross joins is not always the best solution - especially when it would involve doing a
cross join between very large tables. Cross joins between large tables can take a long time to complete.
In this case, it might be best to find an alternative way to achieve the end reporting goal without using
cross joins.
Steps: B. Enable cross joins for the query causing the error
1. Open the report in Report Studio.
2. Navigate to the Query Explorer, and then the 'Queries' folder.
3. Click the query that is experiencing the cross join error.
4. In the Properties pane, set "Cross Product Allowed" to "Allow".
5. If the report is run now, the cross join error should disappear.
C. Enable cross joins in the model
1. Open the model in Framework Manager.
2. Click the "Project" menu, and then "Edit Governors..."
3. Set "Cross-Product joins" to "Allow."
4. Publish the package.
5. The report should be able to be run without the cross join error now

Update Report Specification for Multiple Reports without SDK
Business Case:
The business users decided to change the name of a data item in the Cognos package. Unfortunately
there were about 20 reports that used this data item, which means the report author has to open each of
these reports and repoint the query item to the correct one.
Background:
If you are not familiar about what a Report Specification is and would like to get a better understanding,
read this article first: Explaining Report Specification

You may also be interested in learning how to quickly update a single report with multiple queries for
data item name changes. Check out this article: Update Report Specification without SDK

Example:
Let's take the first business case I mentioned above. Suppose that you have 20 reports have the query
item, [Billing Address]. On top of this the term "Billing Address" is used in multiple pages and multiple
places in the reports (header, column title, foot notes etc). The report user comes to you, the author, and
requests you to change all references to Billing Address to Shipping Address, which already exists in the
package.

Solution:
We will be using the Report Deployment option in Cognos to do the bulk update. Note that you will need
access to Content Administration to be able to use this approach.

Implementation:
In this case, editing the report in report studio to find every instance of [Billing Address] and changing it
to [Shipping Address] is a tedious process. It is highly inefficient too. Here is a quick way to change the
report.
Prepare the Deployment Content:
In the "Public Folders", create a folder called "Deployment".
Copy all the reports that need to be updated into this folder.
Create Export Job:
From the "Launch" menu in Cognos Connection, click "IBM Cognos Administration".
Select the "Configuration" tab and click on "Content Administration" on the left pane.
Create a new "Export" and specify a name of your choice. For our example, let's call it, "Report
Spec Update"
In the next screen, under "Deployment Method", select the option "Select public folders and
directory content" and click "Next".
Under "Public folders content" section, click "Add" and add the "Deployment" folder.
Select the appropriate options from the "Options" section.
Go through the rest of the screens like you normally would and enter a name for the archive in
the last screen (E.g. report_spec_update).
Save and Run the export job once.
Update the Specification:
Login to the Cognos server (Use remote desktop connection if Windows, SSH if Linux).
Navigate to the deployment folder: <cognos_install_dir>/deployment
You will find a zip file with the archive name you specified when creating the export
(report_spec_update.zip).
Copy the zip file to a different folder.
Unzip the contents of the zip file. It will produce 3 files: content.xml, exportRecord.xml and
package1.xml.
The file we are interested is the package1.xml. Open this file in a text editor.
Note: This is the most important step of the entire process. If your cognos server is running on a
linux environment, then the editing must be done in the linux server itself, in vi editor. Do not copy the
zip file or the xml files to your windows desktop for editing since this screws up the file encoding.

Once you have the file open in the text editor, do a find and replace for the data item name that
you are trying to update. For example, replace all occurrences of [Business
View].[Customer].[Billing Address] with [Business View].[Customer].[Shipping Address]
Save the file package1.xml.
Zip the 3 files to a new archive.
Copy the zip file back to the Deployment folder in the Cognos server.
Create Import Job:
Log in to Cognos Connection and navigate to Content Administration.
Create a new Import and from the list of archives, select the new zip file that you just created.
Run the Import.
The reports in your "Deployment" folder will be updated with the changes you made in the XML
file.
That's it !!! The same task, if done manually would take hours to complete and you would not be sure if
you updated all the places. The steps above might seem like a long process but when I tested this, the
entire process took me about 5 minutes.

If you are in a daring mood, you can expand the approach to the entire content store instead of
exporting only the Deployment folder. As long as you keep a copy of the zip file you exported, you are
fine.

If you have made a mistake during the update, or if you find out that you have changed more reports
than necessary, you can always import the original export back again and you will be right where you
started.

Remember.. There is more than one way to skin a cat.. Let's do it the easy way.

Create a Report with Collapsible Hierarchy
Keywords: Collapsible Hierarchies OR Expandable List Report OR Tree Structured Report

Business Case:
Collapsible hierarchies are useful when you have multiple levels of grouping and subtotals in a report and
you don't want to display all the data at once. When the report loads, it should display only the top level
data. Users should be able to expand the group value that they are interested in and the sub groups for
the expanded groups should display. If there is another level within the subgroup, then the users should
be able to expand the subgroups as well.

In Essence, the Report Studio list report should behave in a fashion similar to, but not the same as, an
Analysis Studio report. This is an indirect way of achieving drill down functionality for relational data.
This can be achieved using a drill through report with itself as target, but the advantage of this approach
is that the uses will see the results instantly without having to rerun the report.

Environment: Cognos 8.4.1, Report Studio, Javascript, HTML

Example:
To understand the business case better, look at the following example. Here's how the tabular data looks
like:

We have three levels: Group A, Group B and Group C. The report should be grouped by Groups A and B.
A traditional grouped report will look like this:

This is fine if the number of rows is less. As the data set grows, there might be too much data crammed
in the report that the users can't analyze the data better.

Once the collapsible hierarchy solution is implemented, here's how the report will look like when it loads:

The user will see only the high level information. Looking at this, it is evident which group is performing
well and which one is not. Now the users can drill down into the group they are interested in by just
clicking the + icon next to the group. When the groups are expanded, the report will look like this:

Now the users can see the subgroups in the respective groups. Since this is a two level grouping, the
user can drill down one more level deeper to see the detailed data, which will look like this:

Users can collapse the groups by clicking on the - icon next to the parent.

Solution:
The collapsible hierarchies are build using Javascript on traditional list report. Since this is javascript
based, it can work only when the user executes the report in HTML format. See how the report looks
when the same report is executed in PDF format:

It looks very similar to the report in HTML format when all the groups are expanded, but the +/- icons
are missing.
Note:
You need the image files for the "plus" and "minus" signs. The javascript code used here references
expand_plus.gif and expand_plus.gif in the <c8_installation_directory>/webcontent/pat/images folder. If
your environment doesn't have these files you download them from the links below and place it in the
correct folder on your server:
Plus Sign
Minus Sign

Implementation:
We start by preparing the layout for a collapsible structure. Even though the columns Group A and Group
B are grouped in this report, you will notice that the detail section of this report has individual cells
instead of a merged cell. This can be achieved by following these steps:
Create a simple list report with all the required columns. (I am going to refer to the grouped
columns as A and B. Substitute accordingly in your case.)
Group columns A and B.
From the "Structure" menu, go to "Headers & Footers --> List Headers & Footers". Alternatively,
you can use the "Headers & Footers" icon in the toolbar.
In "List Headers & Footers", check the following items:
o List Header
o List Footer
o Group A Header
o Group B Header
So far, the list report layout should look like this:

Now, CUT (don't delete) the details section of Group A and Group B (see selected items in the
above image).
Unlock the items (using the icon in the toolbar or from Structure menu) and delete the texts "List
Page Header" and "List Page Footer". The layout should now look like this:

Next lock the items and from the Insertable Objects Pane --> Data Items tab, add back Group A
and Group B to the beginning of the list report.
Once again Unlock the items and CUT "Group A" and "Group B".
Then, one after the other, select Group A Header and Group B Header and click "Split Cell". After
this, all rows of the list report, detail and summary will be evenly spaced without any merged cells and
the report should look like this:

Next, unlock the cells and drag "Group B" to the second column.
Now the first cell of the rows "Group B" and "Group C" are empty. We need to add a blank text
item, so that the javascript can recognize it as a child row and collapse it.
Drag a text item to first cells of Group B and Group C rows. You don't have to enter any text, just
put a few white space characters (I put 2 spaces). See screenshot below:

Now comes the Javascript code. We will be using 3 scripts.
The first script, which is also the main script will be placed in the "List Header". In the image
above, it's the first blank row below the titles. Let's call this "Script 1".
Unlock the cells, drag an HTML item to the List Header and place the following script inside:
<!-- Script 1: Master Script -->
<span id="ExpandedTable"> </span>
<script>

var displayStyle = "";
var noDisplayStyle = "none";

var currentRow = 0;

// This function expands/collapses a table where the first columns have +/- icons
function ExpandCollapse(el,loc) {
// change icon
el.src = "../pat/images/expand_" + (isPlus(el) ? "minus" : "plus") + ".gif";
var tr = el.parentNode.parentNode; // the current row

currentRow = tr.rowIndex;
showLines(el);
}

function showLines(el) {
var show = true; // to show lines or not

// Grab the ROW that was clicked and the TABLE that contains it
var tr = el.parentNode.parentNode; // the current row
var tbl = tr.parentNode.parentNode; // the table
var cid = el.parentNode.cellIndex; // the index of the column

if (isPlus(el)) {
show = false;
} else {
show = true;
}

while (currentRow < tbl.rows.length-1) {
currentRow++;
var trCurrent = tbl.rows[currentRow];
var index = findIconInRow(trCurrent, 0); // return the index of the first img
if (index >= 0 && index <= cid) {
trCurrent.style.display = displayStyle;
currentRow--;
return; // found the next line with icon in the same column; return
}

if (!show) {
trCurrent.style.display = noDisplayStyle;
} else {
trCurrent.style.display = displayStyle;
var iconIndex = findIconInRow(trCurrent, cid + 1);
if (Number(iconIndex) > -1) {
var icon = trCurrent.cells[iconIndex].firstChild;
showLines(icon);
}
}
}
}

function isPlus(el) {
return el.src.indexOf("minus") == -1;
}

function hasIcon(cell) {
// return true if this cell has an img
if ((Number(cell.childNodes.length)) == 0) {
return false;
}
var c = cell.firstChild;
if (c != null) {
return (c.tagName == "IMG");
}
return false;
}

function findIconInRow(trCurrent, cid) {
for ( var i = cid; i < trCurrent.cells.length; i++) {
if (hasIcon(trCurrent.cells[i])) {
return i;
}
}
return -1;
}

function StartHidden() {
var q=document.getElementById("ExpandedTable");

// get the table
tbl = q.parentNode.parentNode.parentNode.parentNode;
var isFirstRow=true;

for ( var i = 0; i < tbl.rows.length; i++) {
var trCurrent = tbl.rows[i]; // the current row
var d = trCurrent.cells[0]; // first cell
var c = d.firstChild;

if (i < 2 || c.tagName.indexOf("IMG") != -1) {
c = c.src; // leave it visible, since it has + icon
for ( var j = 1; j < trCurrent.cells.length; j++) {
trCurrent.cells[j].width="1";
}
}
else {
trCurrent.style.display = "none"; // hide the row
}
}
}

</script>
With the first script in place, the report layout will look like this:

The second script is a wrapper script that will be placed around "Group A" and "Group B". This
script will make the entries clickable. Let's call them Scripts 2a and 2b.
With the cells unlocked, drag two HTML items, one before the data item and one after. See
screenshot below for better understanding:

Place the following code in Script 2a:
<!-- Script 2a: Wrapper Script -->
<img onclick='ExpandCollapse(this,"A_img")' src='../pat/images/expand_plus.gif'
style='cursor:pointer;vertical-align:middle; margin-right:2px'/>
<span onclick='ExpandCollapse(this.parentNode.firstChild,"GroupA")' style='cursor:pointer'>
Place the following code in Script 2b which completes the wrapper script:
<!-- Script 2b: Wrapper Script -->
</span>
The last script (Script 3) will be placed in the list footer. This script will collapse all the headers
when the report loads. All it does is to call the StartHidden() function defined in the Mater Script.
<!-- Script 3: Start Hidden -->
<script>
StartHidden();
</script>
Now, if you run the report, it will load with all the groups collapsed (as shown in the 3rd image from
top).

How to Save Report Outputs to a File Location on a Per Report Basis
Problem:
By default, report output files are only saved in the content store. This document describes how to
leverage IBM Cognos 8 BI 8.3 functionality to have the option of saving a copy of any report output in
another file location outside of IBM Cognos 8 BI.
Resolving the problem
To use this feature, you must first configure a root directory in Cognos Configuration and then an
administrator must then set the file location in Cognos Administration. Steps below.
NOTE: When the property CM.OUTPUTLOCATION is set for the ContentManagerService service, all
reports will be saved to the file location.
Remove the CM.OUTPUTLOCATION parameter in order to save report outputs to a file system outside the
content store on a per report basis only.
Steps:
Part A: Configure a root directory in Cognos Configuration
1. Create a shared directory (folder) in Windows (this will not work in Unix, or Linux environments).
Tip: Ensure that the directory is accessible to users and separate from the installation directory. For
example, in a distributed installation, an archive folder such as \\servername\directory could be used.
2. On the Content Manager computer, start Cognos Configuration.
3. From the Actions menu, click Edit Global Configuration.
4. In the Global Configuration window, click the General tab.
5. For Archive Location File System Root, type a URI using the format as shown below:
file://\\servername\directory
6. Ensure that the the user starting the Cognos service has full permissions on the Share. Also ensure that
the share is in the same domain as the Cognos server.
7. To confirm that the correct location will be used, click Test.
8. Click OK.
9. In the Explorer window, click Data Access, Content Manager.
10. For the Save report outputs to a file system property, click True.
11. To test the connection to the report output directory, from the Actions menu, click Test.
12. Ensure that you DO NOT have "localhost" for the server name in the configuration. Change this to either
the hostname of the server or the fully qualified domain name. Leaving the server name as localhost will
cause errors when attempting to save files to a network share.
13. From the File menu, click Save.
14. Restart the Cognos service to let the modifications take effect immediately

Part B: Define File System Locations in Cognos Connection
1. From Cognos Connection, click on Launch (top right)
2. Click Cognos Administration
3. Click on Configuration tab
4. Click Dispatchers and Services (left side)
5. Click the Define File System Locations button ( top right)
6. Click New
7. Type the name (this name will be displayed when you use Run with options and then you would choose
to save report -> Advanced options-> Save to file System-> click on Edit the options then you rename
your report if you want. Under Location you will see the name of folder you created in this step)
Example: you can call it Test
8. Type description, screen tip
9. Specify the name of the folder that will show up under your shared folder. (This folder will show up first
time you select RunWithOptions and save report to new Location). Example: name it CogTest
10. Select Finish.
Part C: Saving a report to the file system
1. From Cognos Connection, go into the Run with options of a report
2. Go Advanced options --> Save to file System --> click on Edit the options if you want to rename your
report. Under Location, you will see the name (Test) of the folder that you created in Part B step 7.
3. After running the report check the shared folder that was created in Part A step 1.

Cognos Concepts: Stitch Query in Cognos Reporting Explained
So what exactly does it mean when Cognos performs a stitch query? Lets start with a business scenario
and question:
A Manager asks a Report Developer to provide a report showing a comparison between Actual Sales and
Forecast Sales for any years we have data.
But these measures come from two completely separate facts: the Forecast Fact and Sales Fact. How
would Cognos understand their relation to each other? To achieve this Cognos uses a conformed
dimension(s) (dimensions that occur in both facts) as a common data point. Since the Manager has
requested the attribute Year as the granularity, we will use the dimension which Year is a part of: Time.
The example below shows how the Time dimension for each fact is used to bridge the two subject areas:

Now that we have a way to relate the two facts, lets create an actual report. The Report Developer is
going to create a list report by dragging on three items:
Year | Actual Sales | Forecast Sales
Behind the scenes, Cognos will need to first perform a query for each fact separately to retrieve each
year/measure combination:

Cognos will then stitch the two queries together on the common Year data points with a third stitch
query, displaying this to the user:

From a technical standpoint Cognos is performing a full outer join between the queries. This can also be
done using measures from multiple facts. While seemingly simple to the user, behind the scenes Cognos
does the heavy lifting and gets surgical with stitch queries.

Technique show multiple rows in one single row with comma separate without using
Repeater Controls
For example you have two columns in database School and Grades like below

School Grade
====== ========
M105 01
M105 02
M105 03
M105 04
M205 05
M205 02
M205 01

And if you want to show these as a comma separated values like

School Grade
======= ========
M105 01,02,03,04
M205 01,02,05

To achieve this with out using the repeater control in report to avoid performance issues
follow this technique by creating a data source query subject in FM and use that in the
report.

Oracle:

select
SCHOOL.SCHOOL_CODE ,
( listagg(SCHOOL.GRADE_NUMBER_CODE,', ') within group

(order by SCHOOL.GRADE_NUMBER_CODE)) AS "GRADE"
from
ODS.SCHOOL SCHOOL
group by
SCHOOL.SCHOOL_CODE
Javascript - Removing first 2 items from a
value prompt
When creating a value (drop down list) prompt for a Cognos 8.3 report, the first 2 lines in the drop down
prompt consist of the field name and then dashes, before showing the actual data.

For example, for "Fiscal Year", it shows:
(line 1) Fiscal Year
(line 2) ----------
(line 3) 1995
(line 4) 1996
etc.

How can the first 2 lines from the value prompt be removed?
Answer
Note: This technique uses JavaScript against underlying report objects in a Cognos BI report. For
this reason, there is no guarantee that reports created using this technique will migrate or
upgrade successfully to future versions without requiring modifications. Any such modifications
are the responsibility of the report designer.

// Licensed Material - Property of IBM
// Copyright IBM Corporation 2003, 2009

Using this technique, a problem arises in Cognos 8.3 INR with cascading prompts.
After the first cascade, the first 2 items from the value prompt are again visible.
This problem does not occur using Cognos 8.3 SP1 or greater.
When using Javascript, it is recommended to be at Cognos 8.3 SP1 or greater.

1. In the properties of the value (drop-down) prompt, specify a value for the name property (under
Miscellaneous section).

Name property used for this example: Prompt1

2. Drag and drop an HTML object from Toolbox tab to the prompt page after the value prompt.
3. Put in the following javascript code to remove the first 2 entries in the value prompt:

<script language="javascript">
var f = getFormWarpRequest();
var list = f._oLstChoicesPrompt1;

list.remove(1);
list.remove(0);
list.removeAttribute("hasLabel");
list.options[0].selected = true;

canSubmitPrompt();
</script>

4. If the value prompt has been created on the main report page with the autosubmit property set to Yes,
and selecting a value, do note that the value prompt will display the first entry in the prompt, instead of the
selected entry after the autosubmit occurs.
To correct this behavior use the following javascript in place of the javascript outlined in step (3) above:

<script language="javascript">
var f = getFormWarpRequest();
var list = f._oLstChoicesPrompt1;

list.remove(1);
list.remove(0);
list.removeAttribute("hasLabel");
</script>



--multiple rows in one single row with comma separate without using Repeater
Controls
--Comma Delimited List

--Oracle

SELECT GR.REGION_EN "Region",
(LISTAGG(GR.COUNTRY_EN,', ')WITHIN GROUP (ORDER BY GR.REGION_EN))AS "Country"
FROM gosalesdw.GO_REGION_DIM GR GROUP BY GR.REGION_EN

--SQL

select distinct GR1.REGION_EN,
STUFF(
(SELECT ', ' + convert(varchar(10),GR2.COUNTRY_EN, 120)
FROM gosalesdw.GO_REGION_DIM GR2
where GR1.REGION_CODE = GR1.REGION_CODE
FOR XML PATH (''))
, 1, 1, '') AS Country
from gosalesdw.GO_REGION_DIM GR1;

You might also like