+ All Categories
Home > Documents > PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10....

PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10....

Date post: 06-Oct-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
27
PowerPlay Macro Samples
Transcript
Page 1: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

PowerPlay Macro Samples

Printing this Book
To print this book, use the Print command (File menu). For best results, it is recommended that printing be done on a postscript printer.
Page 2: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

<HEAD><meta name="last-review" content="25-06-2001"><meta name="title" content="PowerPlay Macro Samples"><meta name="product" content="powerplay client"><meta name="version" content="6.5"><meta name="prodversion" content="powerplay client-6.5"><meta name="area" content="support"><meta name="classification" content="documentation"></HEAD>

Page 3: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or technical inaccuracies may exist. Cognos does not accept responsibility for any kind of loss resulting from the use of information contained in this document.

This page shows the publication date. The information contained in this document is subject to change without notice. Any improvements or changes to either the product or the document will be documented in subsequent editions.

This text contains proprietary information which is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, stored in a retrieval system, transmitted in any form or by any means, or translated into another language without the prior written consent of Cognos Incorporated.

U.S. Government Restricted Rights. The software and accompanying materials are provided with Restricted Rights. Use, duplication for disclosure by the Government is subject to the restrictions in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, or subparagraphs (c) (1) and (2) of the Commercial Computer Software - Restricted Rights at 48CFR52.227-19, as applicable. The Contractor is Cognos Corporation, 67 South Bedford Street, Burlington, MA 01803-5164.

Copyright

PowerPlay version 6.0.

This edition published 1998.

Copyright © 1998 Cognos Incorporated.

Portions Copyright © Microsoft Corporation, One Microsoft Way, Redmond, Washington 98052-6399 USA. All rights reserved.

Portions Copyright © 1984-1996 Faircom Corporation. All Rights Reserved.

Portions Copyright © 1986 by University of Toronto. Written by Henry Spencer. Not derived from licensed software.

Portions Copyright © Three D Graphics, Inc.

Cognos, the Cognos logo, the Cognos tag line "Better Decisions Every Day," Impromptu, PowerPlay, PowerCube, Scenario, 4Thought, DataMerchant, PowerHouse, RealObjects, COGNOSuite, and Cognos Accelerator are trademarks of Cognos Incorporated. All other trademarks mentioned are the property of their respective owners.

Page 4: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Table of Contents

Macro Samples ........................................................ 5

Overview .......................................................................5Adding Levels Sample Macro.............................................7Adding Levels Sample Macro.............................................8Adding Lowest Level Category 1 Sample Macro....................9Adding Lowest Level Category 2 Sample Macro..................10Customize Report Sample Macro ......................................12Dialog Function Sample Macro.........................................14Dialog Statement Sample Macro.......................................15Drill Down Specified Level Sample Macro...........................15Find in Report Sample Macro ...........................................17Graphing Properties Sample Macro...................................18Portfolio Briefing Book Report Sample Macro ......................19Publish as HTML Sample Macro........................................20Report Sorting Sample Macro...........................................22Scroll Bar Toggle Sample Macro.......................................23Standard Reporting Sample Macro....................................24Summary Bar Toggle Sample Macro..................................25

PowerPlay Macro Samples iii

Page 5: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,
Page 6: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

OverviewPurpose

PowerPlay includes a library of sample macros. You can find these sample macros in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory, where PowerPlay is installed.

These sample macros demonstrate the power and versatility of the macro language and act as templates that you can customize for your applications.

Other Sources of Macro Examples

The online help system includes examples of how to use the OLE interface for Cognos Business Intelligence applications. Customize these examples to suit the business requirements of your organization. There are a number of small help examples included. The macro examples are meant to show PowerPlay users examples of the syntax and context of OLE Automation topics. These examples do not include error checking to ensure a user has followed any pre-requisites needed before running the example macro. For example, if a macro requires a report to be open in order to run, it will not work for a user who does not have a report open.

The Cognos Macro Recipe Book contains sample ingredients and recipes for building your own automated macros. This book teaches you how to use Business Intelligence OLE automation objects, collections, methods, and properties in a macro. It does not teach the fundamentals of macro programming. This online book is updated as more OLE capabilities are exposed for each Cognos Business Intelligence product.

If you are a Cognos partner or have a current support contract, you can access the Macro Recipe Book in the Cognos Business Intelligence Online Library at

http://www.cognos.com/htsup/biresource/int_lib.html

PowerPlay Macro Samples 5

Page 7: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Note: Your User Name is your Customer Number. Your Password is your Customer Number plus the first three alphabetic characters of your company name in UPPERCASE.

Setup

You can run a sample macro several ways:

• using the Macro command on the Tools menu in PowerPlay

• using the Customize Toolbars command on the Tools menu in PowerPlay to set up a Launch button (for more information, see Set Up a Launch Button in the PowerPlay online help)

• at startup

• using a command line option

• before you open a report

• using the PowerPlay administrative macros

• using CognosScript Editor

• through Scheduler.

• Using Scheduler, you can coordinate your macros to automatically run at set dates and times regardless of whether you are at your computer. Scheduler can run macros completely unattended, because you can specify security parameters for your databases and catalogs. You can also automate Scheduler; it has a fully exposed OLE interface. That is, you can run a macro to set a scheduled task.

Some macros run better using a specific method. See the macro sample discussions on the Setup tab for each sample; it suggests the best method for running the macro.

Customizing the Sample

You can copy, edit, and then use the macro samples for your applications. Because the CognosScript language is compatible with Visual Basic, you can edit any macro sample using

• the CognosScript Editor

• any text editor, such as Notepad

• any Visual Basic compatible macro editor

When you write or edit a macro using a text editor, you cannot compile or run it from the editor. You must compile and run the macro in the CognosScript Editor or another Visual Basic compatible macro editor.

When you customize a macro sample, you can cut and paste portions of the macros. Before you do so, copy the macro to a different directory or save it under a different name.

Note: If you cannot find the macro samples, refer to the PowerPlay Installation Guide for installation instructions. You must install Transformer, PowerPlay, and the Samples. These components are installed for a typical installation.

6 PowerPlay Macro Samples

Page 8: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Adding Levels Sample MacroPurpose

Adds categories to a nested crosstab report for a specific level.

Discussion

This sample macro creates a new Reporter report and adds new categories to it using the Add and AddLevel methods. This macro demonstrates adding categories to a nested crosstab at a specific, existing level, as well as adding a new level of categories. Levels are numbered from 0 (the level closest to the data) outward. For example, where a financial crosstab has levels for Years and Months, followed by the corresponding data, level 0 would be for Months and level 1 would be for Years.

Main Features• Looks at the Cognos.ini file for the location of where PowerPlay was

installed.

• Displays a message box outlining that a new report will be created. It then creates a new report from Great Outdoors 6.0.mdc. When the macro creates a new report, it prompts you to indicate that it will add a new level of row categories for Locations.

• Changes the report to show that the macro added a new level of rows to the report: locations for Europe, Far East, and Americas. The new level of rows is in the column closest to the data, level 0.

• Adds categories one level below Channels as new rows. It adds the categories for Channels (Independent, Sports Chain, Camping Chain, Mass Marketer, and GO Outlet) at the same level as the existing rows that are closest to the data.

PowerPlay Macro Samples 7

Page 9: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Adding Levels Sample MacroSetup

Run the macro, Adding Levels.mac, from PowerPlay using the Macro command on the Tools menu. You can find this macro in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. The macro looks for the file Great Outdoors 6.0.mdc in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory. If the macro cannot find this file:

1. Open the macro file in either CognosScript Editor or Notepad.

2. Set the correct subdirectory for the Great Outdoors 6.0.mdc file. Only the subdirectory information is needed because a function in the macro determines where PowerPlay was installed.

3. Save the .mac file, compile it, and then run the sample macro again.

While the macro runs, it displays an information message. Click OK to continue.

When the macro finishes, look at the report created in PowerPlay. The macro does not save this new report.

Customizing the Sample• Use the Add method to add more categories to the same level.

• Use the AddLevel method to add a nesting level of categories as rows or columns.

• Change any references to the Great Outdoors 6.0 cube to another .mdc file.

• Change the comments and MsgBox statements to match the name of your cube.

• Remove the Msgbox prompts that indicate the progression of the macro.

• Add categories and levels to other existing reports.

8 PowerPlay Macro Samples

Page 10: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Adding Lowest Level Category 1 Sample Macro

Purpose

Drills down to the lowest-level category for a specified row or column.

Discussion

This sample macro uses the AddLowestLevelCategories method to drill down to the lowest-level category for a specified row or column. The active report displays the drill-down data, along with other rows and columns in the original report.

Main Features• You can use this macro for any report that has one or more drill-down

paths.

• The modified report contains the categories and associated data based on the lowest-level categories in the drill-down path; the other categories from the original report are also included in the modified report.

• Ensures that PowerPlay is in Reporter mode. If it is not, it automatically switches from Explorer to Reporter mode.

• This macro is similar to the Adding Lowest Level Category 2 Sample Macro. Use this macro when you want to include the original rows and columns in the modified report, whereas the other sample macro only contains the selected row, column, or row and column combination with the drill-down categories and corresponding data.

Setup

To run this macro, Add Lowest Level Category 1.mac, use an existing report or one of the sample reports that accompany PowerPlay, such as Advanced Subset.ppr in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory. The report you use must contain at least one drill-down path.

Open a report and run this macro from within PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. You must select a row or column prior to running the macro. Otherwise, the macro displays an error message.

PowerPlay Macro Samples 9

Page 11: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Select a label to drill on a row or column. If you use the Advanced Subset.ppr report, select the Sports Chain cell. If you are using another report, ensure that you select a row or column where the pointer appears as a plus sign (+), indicating a drill-down path. If you select a row or column that does not have an associated drill-down path, the macro stops without further execution.

When the macro finishes, the active report displays the specified drill-down data, along with other rows and columns in the original report. If you used the Advanced Subset.ppr report, and selected the Sports Chain cell, the macro includes the lowest-level categories in the report for that column.

If the selected row or column was one level above the lowest level, position the cursor over the original row or column you selected. Since the macro drilled down to the bottom of the hierarchy, the pointer changes to a plus sign (+) with an up-arrow, indicating that you can drill up. Otherwise, click Undo from the Edit menu to undo the macro actions.

The macro does not save the modified report.

Customizing the Sample• Display the drill-down results without the original columns.

• Add prompts to indicate that the user selected a non drill-down path.

• Save the modified report.

Adding Lowest Level Category 2 Sample Macro

Purpose

Drills down to the lowest-level category for a specified row, column, or row and column combination.

Discussion

This sample macro uses the AddLowestLevelCategories method to drill down to the lowest-level category for a specified row, column, or row and column combination, and adds the lowest-level categories to the Reporter report. The modified report displays the selected row, column, or row and column with the corresponding drill-down data. All other rows and columns are deleted from the active report.

10 PowerPlay Macro Samples

Page 12: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Main Features• You can use this macro for any report that has one or more drill-down

paths.

• The modified report only contains the categories and associated data based on the lowest-level categories in the drill-down path.

• Ensures that PowerPlay is in Reporter mode. If it is not, it automatically changes from Explorer to Reporter mode.

• This macro is similar to the Adding Lowest Level Category 1 Sample Macro. Use this macro if you do not want to include the original rows and columns in the modified report, whereas the other sample macro contains the selected row, column, or row and column, with the drill-down categories and corresponding data.

Setup

To run this macro, Add Lowest Level Category 2.mac, use an existing report or one of the sample reports that accompany PowerPlay, such as Advanced Subset.ppr in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory. The report you use must have at least one drill-down path.

Open a report and run this macro from within PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. You must select a row, column, or row and column combination prior to running the macro; otherwise, the macro displays an error message. If you select a row from the active report, all other rows are deleted from the report. The columns remain the same, and only the selected row and its categories remain in the report. If you select a column from the active report, all other columns are deleted. The rows remain the same; only the selected column and its lowest-level categories remain in the report.

If you use the Advanced Subset.ppr report, select the Sports Chain row. If you are using another report, ensure that you select the row, column, or row and column where the pointer appears as a plus sign (+). If you select a row or column that does not have an associated drill-down path, the macro stops.

When the macro finishes, the modified report displays the specified drill-down data. Unlike the Add Lowest Level Categories 1 sample, this macro only displays the lowest-level categories for the selected row or column, as well as the row or column that you selected. If you use the Advanced Subset.ppr report and select the Sports Chain cell, the macro includes the lowest-level categories for Sports Chain.

PowerPlay Macro Samples 11

Page 13: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

If the selected row or column was one level above the lowest level, position the cursor over the original row or column you selected. Since the macro drilled down to the bottom of the hierarchy, the pointer changes to a plus sign (+) with an up arrow, indicating that you can drill up. Otherwise, click Undo from the Edit menu to undo the macro actions.

The macro does not save the modified report.

Customizing the Sample• Display the drill-down results with the original columns.

• Add prompts to indicate that the user selected a non drill-down path.

• Save the modified report.

Customize Report Sample MacroPurpose

Adds report items as rows, columns, or layers when you specify a high-level dimension with a corresponding level.

Discussion

This sample macro modifies a Reporter report using the CategoryList, DimensionLine, Remove, Select, and AddLevel methods. It demonstrates the creation of a report by removing the current categories and replacing them with a particular level for the row, column, and layer categories that you specify. This macro enables you to immediately access data for specific high-level row, column, and layer dimensions for a desired level.

You can customize the Customize Report.mac file to include the original and new categories in the report.

Main Features• Uses the DimensionLine method to search for all of the high-level

dimensions in the current report in order to populate the drop-down list boxes for the dimensions in the Add Rows, Columns and Layers dialog box.

• Displays a dialog box from which the user can select a dimension for a row, column, and layer from a drop-down list.

• Uses the CategoryList method to obtain a list of categories to include in the new report, based on the specified dimension(s) and corresponding level(s). Then, the macro uses the Select, Remove and Add methods, and displays the new report in the PowerPlay window.

12 PowerPlay Macro Samples

Page 14: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Setup

To run this macro, Customize Report.mac, use an existing report or one of the sample reports in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from within PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

While the macro runs (for an open report only), the macro displays a dialog box that prompts for a specific row, column, and layer that you can add to the report. For this sample, you can use an existing report or the Great Outdoors 6.0.mdc cube. The report you create must contain, at a minimum, one row and one column, or a single row, column, or layer.

You can select any combination of row, column, or layer items. Opposite a specified row, column, or layer dimension, indicate the level that the report is to contain. If the level specified for rows, columns, or layers is 0, the macro uses the highest level for the dimension. If you specify a level that does not exist, the macro uses the lowest-level for the specified dimension.

To run this sample macro, you can use Great Outdoors 6.0.mdc. In the Rows text box, select Years. In the levels text box opposite Rows, type 2. (Level 1 is years, level 2 for quarters, and level 3 for months.) Click OK to continue.

When the macro finishes, the modified report displays the specified data for the categories (Reporter), and the original rows and columns in the report are replaced.

This macro does not save the modified report.

Customizing the Sample• Include the original categories in the report.

• Add prompts to indicate that users need to specify at least one dimension for a row, column, and layer.

• For a specified dimension, automatically populate the Levels text box with the lowest-level value for a dimension. This enables the user to see the maximum levels for their specified dimension without having to type a large value, such as 99, to ensure the maximum-level number.

PowerPlay Macro Samples 13

Page 15: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Dialog Function Sample MacroPurpose

Creates a dialog box that will redisplay, if necessary.

Discussion

This macro is a CognosScript sample that displays a simple dialog box. It includes a function to handle interactions with the dialog box. When you click a button, the value of that button is stored in a variable. The value of this variable is used by the function to determine if the dialog box should be redisplayed.

Main Features• Creates a simple dialog box with four standard buttons. The macro

also includes a function to process your selections.

• Displays a dialog box that uses a DialogFunction to handle user interactions with the dialog box. When the user clicks a button, the value of that button is stored in a variable. The function uses this variable to determine if the dialog box should be redisplayed.

• The Control_Dialog function is linked to the dialog Show_Always_dlg. Since this function is declared on the Begin Dialog statement, this function takes action based on the Action% value passed to it by the dialog.

• For this sample, the macro does not do anything specific with the returned value other than use the dialog function statement to avoid having the Cancel button raise an error, as it would if the dialog statement was used instead.

Setup

To run this macro, Dialog Function.mac, use the Macro command on the Tools menu. The macro is stored in the \Program Files\Common Files\Cognos Shared\CogMac\5.0\ directory where the CognosScript editor was installed.

This macro displays a dialog box that you can use as a template. You can click any button (OK, Cancel, Button 1, or Button2) or you can type directly into the text box.

Customizing the Sample• Change the dialog code to add your own button labels or

instructions.

14 PowerPlay Macro Samples

Page 16: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Dialog Statement Sample MacroPurpose

Creates a dialog box.

Discussion

This macro is a CognosScript sample that displays a simple dialog box. The Dialog statement gets the value of the pressed button and then closes the dialog box. (Selecting the check box only changes the value of the check box.)

Main Features• Creates a simple dialog box with several standard buttons. You can

easily modify this macro file for use in your applications or use it as a template.

• Displays a dialog box where you can click any button (OK, Cancel, or Button 3), type in a text box, or select a check box. When you click OK, the macro returns messages that state what actions were performed.

Setup

To run this macro, Dialog Statement.mac, use the Macro command on the Tools menu. The macro is stored in the \Program Files\Common Files\Cognos Shared\CogMac\5.0\ subdirectory where the CognosScript Editor was installed.

Customizing the Sample• Change the dialog code to add your own button labels or

instructions.

Drill Down Specified Level Sample MacroPurpose

Shows how to drill down to a specific level category below a selected row or column.

Discussion

This sample macro modifies a Reporter report using the CanDrillDown and TopLevelParentCategory properties and the AddLowestLevelCategories method. It drills down to a level category below the currently selected row or column. This macro enables you to specify the lowest-level for a selected category (all), or a level from 1 to 10.

PowerPlay Macro Samples 15

Page 17: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Main Features• Ensures that PowerPlay is in Reporter mode. If it is not, it

automatically changes from Explorer to Reporter mode.

• Displays a dialog box from which the user can specify a level for their selected row or column.

• Determines if the selected row or column has a drill-down path. If it does have a drill-down path, the macro uses the AddLowestLevelCategories method to add those categories to the new report. Otherwise, it uses the TopLevelParentCategory property to get the name of the dimension that a category belongs to.

Setup

To run this macro, Drill Down Specified Level.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory. The report you use must have at least one drill-down path.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

While the macro runs, the macro identifies the key features by prompting you with a dialog box where you can specify a particular level or type all to drill down a level of the selected category. Click OK to proceed. If you selected a row or column prior to running the macro, the macro immediately runs using that selection. Otherwise, after you specify a category level to drill down to, the macro prompts you to select a row or column.

You can run this macro with the Great Outdoors 6.0.mdc cube. First, select the Outdoor Products column. If you are using another report, ensure that you select the row or column where the pointer appears as a plus sign (+). If you select a row or column that does not have an associated drill-down path, the macro stops.

When the macro finishes, the active report displays the specified drill-down data. This macro displays the selected level categories for the selected row or column, including the original categories. To obtain the categories at the lowest level, type the appropriate value when prompted. If you used the Great Outdoors 6.0.mdc cube and selected the Outdoor Products Column, the macro includes the level categories for Outdoor Products (Back Packs, Cooking Equipment, Sleeping Bags, and Tents).

If the selected row or column was one level above the drill-down path, position the cursor over the original row or column you selected. Since the macro drilled down to the bottom of the hierarchy, the pointer changes to a plus sign (+) with an up arrow indicating that you can drill up. Otherwise, click Undo from the Edit menu to undo the macro actions.

16 PowerPlay Macro Samples

Page 18: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

The macro does not save the modified report.

Customizing the Sample• Use the AddLevel method to add a nesting level of categories as rows.

• Change the comments and MsgBox statements.

• Prompt the user to select a row or column before specifying the level.

Find in Report Sample MacroPurpose

Searches a report for a specific category or set of categories.

Discussion

This macro uses the FindNext method to search the active report for all rows that begin with Go. It applies a predefined style, Good News, to each of the rows meeting the search criteria. A message box displays the total number of rows found that match the given criteria.

This macro demonstrates how to search a report for a specific category or set of categories through automation. It uses Find automation functionality to search through the chosen categories, which can be any combination of rows, columns and layers.

Main Features• Finds specific instances of a word and highlights the rows in the

active report that match a specified search criteria (GO).

• Positions the cursor to the first row in the report so that it can start searching. It then uses the FindNext method to search for rows that begin with the word Go in the rows dimension. When the FindNext method finds a row that matches the criteria, it uses the Style property to apply a style (Good News) to the entire row. Then the macro continues to search the remaining rows for the active report.

Setup

To run this macro, Find in Report.mac, use an existing report or one of the sample reports that accompany PowerPlay, such as Advanced Subset.ppr, in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

While the macro runs, it searches any active report for rows that begin with Go. It then selects each row and applies a style to it.

PowerPlay Macro Samples 17

Page 19: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

You can run this macro with the Advanced Subset.ppr report. If you are using another report, ensure that the report has at least one row whose name begins with Go. If you use a report that does not have one or more rows beginning with Go, the macro displays an error message and stops.

When the macro finishes, it displays a message box indicating the number of rows that matched the specified criteria. The active report displays the report with the Good News style to indicate which rows were found that met the specified criteria.

The macro does not save the modified report.

Customizing the Sample• Prompt the user to specify their own search criteria.

• Prompt the user to open a report instead of using the active report.

Graphing Properties Sample MacroPurpose

Sets the properties of each Graph object in an active report.

Discussion

This sample macro sets the properties for all Graph objects in an active report. Apply this macro to multiple reports that have the same graph type to ensure that they all share the same properties. This macro enables users to quickly change the Graph object settings to either conform to corporate standards, or to view reports using their own preferred settings.

Main Features• Modifies properties for a graph (a Graph object) based on the type.

• Displays a dialog box that notifies the user that changes will be made to the Graph object in the active report. It then determines what types of graphs exist in the report.

• Applies the appropriate predefined properties to the graphs in the active report.

• For each Graph object type, there is a predefined view to apply properties, such as values on graphs, statistical lines, summary rows and columns, indented totals, and gridline values. If the report has two different graphs, then changes are applied to both graphs.

18 PowerPlay Macro Samples

Page 20: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Setup

To run this macro, Graphing Properties.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. You can find this macro in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

While the macro runs, the macro determines the types of graphs are used with the report and applies the appropriate predefined properties.

When the macro finishes, the modified report displays each graph with the preset properties.

The macro does not save the modified report.

Customizing the Sample• Prompt the user to open a specific report.

• Prompt the user to specify predefined properties.

Portfolio Briefing Book Report Sample MacroPurpose

Publishes a report as a Briefing Book page.

Discussion

This sample macro uses the PublishAsBriefingBookPage method to publish an active PowerPlay report as a page in the Portfolio Briefing Book, PBB-Report.pbb. If the report has layers, each layer is published as a separate page in the Briefing Book.

Main Features• Displays a message box indicating that the active report will be

published to the PBB-Report.pbb briefing book.

• Uses the Count property to determine the number of layers for the active report. If the report has layers, the macro publishes each layer as a separate page in the Briefing Book. If the report does not contain layers, the macro only publishes the current page in the Briefing Book.

• Uses the PublishAsBriefingBookPage method to publish the report as pages in the PBB-Report.pbb briefing book for the active report.

PowerPlay Macro Samples 19

Page 21: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Setup

To run this macro, PBB-Report.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. This sample macro requires the Portfolio briefing book PBB-Report.pbb.

When the macro runs, it uses the active report to publish as a briefing book.

When the macro finishes, it displays a prompt indicating that the macro was successful and that you can view the briefing book in the directory \PP6.0 Samples\Cubes and Reports\PBB-Report.pbb under the directory where you installed PowerPlay. If the macro was not successful, it displays an error message.

Customizing the Sample• Prompt the user to specify where to save the resulting briefing book.

Publish as HTML Sample MacroPurpose

Generates HTML for the active report.

Discussion

This sample macro uses the Publish method to output an active report in HTML format so that it can be viewed using a Web browser.

Main Features• Outputs one of your reports in HTML format.

• Uses the Publish method to generate HTML for the active report.

20 PowerPlay Macro Samples

Page 22: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Setup

To run this macro, Publish as HTML.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

To run this macro:

1. Open the macro file in either CognosScript Editor or Notepad.

There are three lines of code that are commented out.'PpRep.publish "<target directory>"'PpRep.publish "<target directory>", false, false, false'PpRep.publish "<target directory>", true

Removing the comment character (') for the first line causes the macro to run without displaying a dialog box, and it publishes all layers. Removing the comment character for the second line causes the macro to run without displaying a dialog box, and it only publishes the current layer. Removing the comment from the third line causes the macro to display a dialog so that the user can decide on how to publish the report.

2. Remove the comment (') character from one of the three Publish commands.

3. Change the <target directory> references to a directory where the HTML files will be placed.

4. Save the file and run the sample macro.

After the macro runs, use one of the other syntax lines and run the macro sample again. Ensure that you change the target directory to avoid overwriting existing files.

Customizing the Sample• Prompt for the reports name and location.

• Specify an output directory and filename in the Publish method to suit your needs.

PowerPlay Macro Samples 21

Page 23: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Report Sorting Sample MacroPurpose

Ranks the top ten rows and sorts them by label in ascending order.

Discussion

This sample macro demonstrates how to use the Rank2 and Sort methods to rank and sort categories within a report through automation. The macro ranks the top ten rows by the last column to the right, which is usually where summary columns are located. Then, the macro sorts the rows by their label in ascending order.

Main Features• Changes the current display of the active report to crosstab format.

• Uses the Rank2 method to rank the rows based on the last column in the collection.

• Uses the Sort method to sort the resulting top ten ranked rows by their label in ascending order, and displays the top ten rows in the active report.

Setup

To run this macro, Report Sorting.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. You can run this macro with the Great Outdoors 6.0.mdc cube.

While the macro runs, it changes the display to the crosstab format, ranks the rows based on the last column, displays the top ten rows, and then sorts the rows by label.

When the macro finishes, PowerPlay displays the modified report; the macro does not save the report.

Customizing the Sample• Prompt the user to select the column they want to rank.

• Prompt the user to sort in ascending or descending order.

22 PowerPlay Macro Samples

Page 24: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Scroll Bar Toggle Sample MacroPurpose

Toggles scrolling on or off for the active Graph object.

Discussion

This sample macro changes the scrollbar setting for the active graph in the current report using the UseScrolling, MaxVisibleBars, and MaxPrintedBars properties

Main Features• Ensures that the graph type is indeed scrollable. The scrollable types

are 3 (simple bar), 4 (clustered bar), 5 (stacked bar), 6 (single line), 7 (multiline), and 8 (correlation), and the non-scrollable types are 0 (crosstab), 1 (pie), 2 (3-D bar), and 9 (scatter).

• Determines if the scroll bar is currently being displayed. If it is displayed, the macro sets the UseScrolling property to False (disables scrolling). If the scrollbar is not displayed, the macro sets the UseScrolling property to True (enables scrolling).

Setup

To run this macro, Scroll Bar Toggle.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

If you select a graph type that does not support scrolling (0,1,2, and 9), the macro stops.

When the macro finishes, PowerPlay displays the modified report; the macro does not save the report.

Customizing the Sample• Notify the user when they attempt to run this macro for a graph that

does not support scrolling.

PowerPlay Macro Samples 23

Page 25: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

Standard Reporting Sample MacroPurpose

Searches for and retrieves categories that are then added to a blank report.

Discussion

This macro creates three subset definitions and then adds the subsets to a new, blank report as rows and columns. A FindQuery subset definition searches for all products that begin with Go. An AdvancedQuery subset definition retrieves all categories belonging to Europe. A ParentageQuery subset definition returns all categories one level below Years. The new categories are then added to a new report. Products beginning with Go (FindQuery subset definition) are added as columns and Locations/Country (AdvancedQuery subset) are added as rows. Then the categories that are one level below Years (ParentageQuery subset definition) are added as the first nesting level of rows.

Main Features• Retrieves all categories that belong to a specified level within a

dimension.

• Uses the FindQuery subset definition to search for specific criteria, for example, Go, and adds the resulting columns to the new report.

• Uses the AdvancedQuery subset definition results to add to the report as rows.

• Uses a ParentageQuery subset definition to return all categories below a specified level, and adds the new categories to a new blank report as the first nesting level of rows.

Setup

Run this macro, Standard Reporting.mac, from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed. The macro looks for the file Great Outdoors 6.0.mdc in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory. As the macro runs, if you get a message that this file cannot be found:

1. Open the macro file in either the CognosScript Editor or Notepad.

2. Set the correct subdirectory for the Great Outdoors 6.0.mdc file. Only the subdirectory information is needed because a function in the macro determines where PowerPlay was installed.

3. Save the .mac file, compile it, and then run the sample macro again.

While the macro runs, the macro displays information messages. Click OK to continue.

24 PowerPlay Macro Samples

Page 26: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Macro Samples

When the macro finishes, look at the report created in PowerPlay. The macro does not save this new report.

Customizing the Sample• Prompt the user to specify the name and location of the cube.

• Prompt the user to specify search criteria.

• Prompt the user to specify components for the subset definitions.

Summary Bar Toggle Sample MacroPurpose

Sets the visibility on or off for summaries of the active Graph object when scrolling is turned on.

Discussion

This sample macro changes the summary visibility setting for the active graph in the current report using the KeepSummaryVisible property.

Main Features• Ensures that the graph type in the active report has a summary

category. The graph types that can contain a summary are 3 (simple bar), 4 (clustered bar), 5 (stacked bar), 6 (single line), 7 (multiline), and 8 (correlation), and the non-summary types are 0 (crosstab), 1 (pie), 2 (3-D bar), and 9 (scatter).

• Determines if the Summary bar is currently being displayed. If it is displayed, the macro sets the KeepSummaryVisible property to False (disables the Summary Bar). If the Summary bar is not displayed, the macro sets the KeepSummaryVisible property to True (enables the Summary Bar).

Setup

To run this macro, Summary Bar Toggle.mac, use an existing report or one of the sample reports that accompany PowerPlay in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Cubes and Reports directory.

Open a report and run this macro from PowerPlay using the Macro command on the Tools menu. This macro is stored in the \Cognos\PowerPlay 6.0\PP6.0 Samples\Macros directory where PowerPlay was installed.

If you select a graph type that does not support scrolling (0,1,2, and 9), the macro stops.

Customizing the Sample• Notify the user when they attempt to run this macro for a graph that

does not support scrolling.

PowerPlay Macro Samples 25

Page 27: PowerPlay Macro Samplespublic.dhe.ibm.com/.../en/powerplay/6.5/pp_mac_samples.pdf · 2008. 10. 17. · PowerPlay to set up a Launch button (for more information, ... Mass Marketer,

Recommended