Creating macros

Macros are fragments of code that you can insert anywhere in the Select statement that defines a query subject. You can include references to session parameters, parameter maps, and parameter map entries. Parameter values are set when you run the query.

When you reference a parameter, you must do the following:

  • Use a number sign (#) at the beginning and end of each set of one or more parameters.

    Everything between the number signs is treated as a macro expression, which is processed at runtime. Framework Manager removes anything that is outside the number signs.

  • Precede each parameter map entry with a dollar sign ($)
  • Use a name that starts with an alpha character (a..z, A..Z)

Do not insert macros between existing quotation marks or square brackets because IBM® Cognos® Framework Manager does not execute anything within these elements.

Procedure

  1. Select the data source query subject you want to modify.
  2. Click Actions, Edit Definition.
  3. On the SQL tab, click Insert Macro to start the Macro Editor.
  4. In the Available components box, click the parameter maps, session parameters, or functions you want to use, and drag them to the Macro definition box.

    Ensure that you type the macro expression between the number signs. If you enter text before or after the number signs, when you click OK, Framework Manager deletes this text.

  5. Insert single or double quotation mark functions.

    Tip: Click the arrow next to these buttons insert quotation marks icon for a menu of choices for placing the quotation marks.

  6. If you want to edit a parameter map or session parameter, click it in the Macro definition box.

    The Parameter Map or Session Parameters dialog box displays. You can set override values for session parameters, add new items, or change values.

  7. Check the macro in the Information box.

    If a macro is incorrect, an error message displays.

    Tip: To clear a macro, click the clear all icon clear all icon.

  8. Click OK.