Creating templates

In all organizations, the reporting suite is required to follow the standard formatting. Similar to other tools and technologies, Cognos Report Studio also allows you to create and use templates in order to maintain the standards, reduce cosmetic errors, and save time.

Getting ready

We will amend the report created in the previous recipe for this.

How to do it...

  1. We have already defined the formatting for crosstab members and hyperlinks. Now go ahead and define standard report header and footer. You might want to put the company logo in the header.
    How to do it...
  2. From the menu, Choose File | Convert to Template.
    How to do it...

    Notice that the Model/Source pane becomes empty and all data items are removed from the report.

  3. From the menu, choose File | Save As. Give the filename as Template. Notice that the icon created for this How to do it... is different than other reports.
  4. Now we will prepare the XML specification of this template to be inserted in the server files. For that, select Tools | Copy Report to Clipboard from menu.
  5. Go to any XML editor and paste the XML specification that we just copied. Now perform the following:
    1. From the <report> tag, remove the xmlns and template attributes. So it should look like this: <report expressionLocale="en-gb">
    2. Add a template tag just above it: <template name="PACKT Sample Template">
    3. Add </template> at the end of the file. (Just after </report>)
    4. Copy the whole specification on clipboard
  6. Now, on the Cognos application server, open the Cognos installation directory. Locate C8_location/webcontent/pat/res/templates.xml file.
  7. Make a backup of the file for fail-over and then open this templates.xml file. Paste the specification that we copied in step 4, under <xmlFragment id="ReportTemplates"> tag. Save the file and close it.
  8. Last step is to update the Resources.xml file. Locate c8_location/webcontent/pat/res/Resources.xml and open in XML editor.
  9. Find the <listItems> tag. Add following line in similar fashion as the existing <listItem> tags.
    <listItem label="PACKT Template" icon="icon_blank.gif" templateName="PACKT Sample Template"/>
    How to do it...
  10. Save the file and close it.
  11. Open new instance of Cognos Report Studio. Notice that a new option appears in the dialog box for PACKT Template.
    How to do it...

    Select this option and check that the template we created initially appears.

Now you can create a new report as usual. You are rest assured that formatting of objects and other components that you placed on the templates are maintained every time you create a new report using this.

How it works...

This recipe looks like a long process but it is a one-time task which is extremely useful. We have already discussed the advantage of having templates.

If you are going to create many reports that need organization standards formatting, some common scripts and components, and generic header and footer elements—it is highly recommended that you take time to prepare a template for it.

It is common to see a Cognos developer opening one existing report, making a copy of it and then updating it—thus using the base report as template. While this serves the purpose very well, there are chances of accidently overwriting the templates. Especially in the case of multi-developer environment, it is suggested that one who has access to server installations performs this operation of defining standard template and rest of the team uses it from New Report dialog box.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset