altering report XML concept code snippet

In continuing with our Report Studio Cookbook series, this month’s cookbook recipe will show you the steps for altering report XML to make bulk changes. This is most commonly used when name changes are made to the FM Model and abandoned data items result.

Difficulty:  Medium

Required ingredients:

– Report XML to modify

– List of changes required

– A text editor of your choice

Scenario

There is a change to the Framework Manager model to accommodate a change in business requirements. There is a data item called “Order method type” that was changed to “Order method type name”. A number of reports utilize this data item and in various areas of the report. You are tasked with updating the affected reports with the new name. You will do so by altering report XML to implement a bulk update technique.

Task: Altering Report XML to Accommodate an FM Model Change

1. Open the affected report in Report Studio.

2. Click Copy Report to Clipboard from the Tools menu.

Copy Report to Clipboard

3. Paste (Ctrl+V) the copied report in a text editor.

4. Utilize the Find/Replace function of your editor.

5. Find Order method type and replace it with Order method type name in the report XML shown in your text editor.

Order Method Name

6. Select all and copy the report XML from the text editor.

7. Open a blank report in Report Studio from the Cognos Connection portal.

8. From the Tools menu, click Open Report from Clipboard.

Open Report from Clipboard

9. The report opens up in Report Studio, and the change from Order method type to Order method type name can be noticed in all the query items that referenced the data item

10. Notice that this is a new report with the change included, and it can either be saved to overwrite the existing report or saved as a new report.

Copying Queries across Reports

There might be cases where a complex query built in one report might have to be used in other report. So instead of creating the complete query from scratch again, we can use the technique below to copy the query xml from one report to the other. We would follow the below steps to accomplish this task.

Task: Altering Report XML to Accommodate an FM Model Change

1. Open the report in Report Studio.

2. Go to Query Explorer and click Queries

3. Click the Query you would like to copy and click Copy from the Edit toolbar.

4. Open the report that you would like to copy the query to.

5. Go to Query Explorer and click Queries.

6. Click Paste from the Edit toolbar.

7. You should now see that the query is available to use in the report.