Macro Script Design

Consider error handling, scheduling, and distribution when you create macro scripts.

Error Handling

A script can be thoroughly debugged and still encounter conditions that cause errors, such as running a script that attempts to open a file that does not exist or is unavailable. When a IBM® Cognos® PowerPlay® user encounters errors, they can respond to the error and continue working. However, when a macro encounters an error, it stops. The remaining macro instructions are not executed unless your macro includes instructions to handle errors.

When you write macros, the goal is to write a macro that is not too dependent on a particular set of conditions. For example, you do not want to create a macro that requires precise and accurate input from the user. By structuring your macros to include IF statements, you can try to anticipate your user's responses.

A macro that functions properly should

  • close any documents the macro opened but the user no longer needs
  • save, or prompt the user to save, a file that should be saved
  • restore the settings of any options the macro may have changed
  • delete any temporary files

Scheduling

If you use IBM Cognos Series 7 Scheduler to run a macro, estimate how long the macro will take to execute. For longer activities, you may want to schedule the macro to run during off-hours to minimize network activity. However, too many large macros, along with other routine network activities, may also affect the successful execution of your macros.

Distribution

You can use any file distribution method available to distribute models, cubes, reports, and macros.

When you define your PowerPlay strategies for automating model, cube, and report distribution, you need to

  • identify repetitive tasks, such as identifying the models, views, cubes, and reports to change or update regularly
  • list the users or user communities that require the files
  • indicate how, and when, each user or user community will receive the updates