COGNOS REPORTNET TIPS AND TRICKS
USING SEARCH AND REPLACE IN XML CODE TO FIX REFERENCES TO OLD FIELD NAMES
If you run a report using the new ODS 8.0 and Cognos 8.3 and get the following parsing error, it could mean the report is referencing a field name that has changed in the new ODS version. There are several methods you can use to modify your report so that it references the new field names. This technique involves copying the XML code to the clipboard, doing a search and replace on the field name, and then re-opening the report from the clipboard. It is particularly useful for more complex reports with multiple queries.
1. Click the details link. In this example, the error details state the object [List of Values].[Academic Period LOV].[VALUE_DESC] does not exist. Click OK to clear the error message which then takes you to the work area of the report.
2. In the Insertable Objects Pane, under the Source tab, expand the LOV validation table that contains the field used in the report. In this case, it is [List of Values].[Academic Period LOV]. Notice [VALUE_DESC] is now called [VALUE_DESCRIPTION].
3. The problem however, is when you click on the data items tab, the query data items still have the old field names. In this case, [VALUE_DESC]. Rather than manually rename all of the data items, you can copy the xml code and do a search and replace. This is particularly useful for complex reports with multiple queries.
4. To do a search and replace, first click Tools, Copy Report to Clipboard.
5. Open Notepad (Start, Programs, Accessories). Click Ctrl-V to paste the xml code to Notepad.
6. Go to the beginning of the code (Ctrl-Home) and click Ctrl-H (Edit, Replace on the Tool bar). Type in the old and new names and click Replace. You will be asked to replace each instance one at a time. It is not recommended that you use "Replace All' as you may accidentally replace a field from a table that still uses the old name. For example, [List of Values].[All Values LOV] still contains a field called [VALUE_DESC] and not [VALUE_DESCRIPTION]. Close the Replace dialog box.
7. While still in Notepad, click Ctrl-A (Select All) and Ctrl-C (Copy)
8. Go back to your Cognos report, and Click Tools, Open Report from Clipboard. A new report has been created.
9. Click File, Save As.
10. Name the new report and click Save.
11. After the report has been saved, check for errors by clicking Tools, Validate Report.
12. In this example, three errors were reported that all relate to one field. [List of Values].[All Values LOV].[VALUE_DESCRIPTION] does not exist. This is because when doing the search and replace, we accidentally replaced a field that still uses the old name. We should've kept [List of Values].[All Values LOV].[VALUE_DESC] instead of replacing it. You can manually correct this in the query of the report.
13. Close the Validation Response box. Then click on the Query Explorer Bar to see the list of queries. Notice SEL_TYPE query uses All Values LOV. We know that field name [List of Values].[All Values LOV]. [VALUE_DESC] has not changed. However it was accidentally modified during the search and replace method. Click on SEL_TYPE to see the data items for that query.
14. In both the Name and Expression property, change DESCRIPTION to DESC.
15. Save and run the report.