Add and execute IBM Cognos automation API functions

Now that you have set up your environment for the IBM Cognos automation API, it's time to add and execute some API functions.

Double-check the references to the IBM Cognos automation API

You might run into some trouble if you're missing some references to the IBM Cognos automation API. Let's double check those first.

Procedure

  1. Open the template file that you created in the last tutorial.
  2. Log into the Planning Sample server. This is the server/datasource which contains the view that you'll be creating multiple Exploration Views from.
  3. Click the DEVELOPER tab.
  4. Click Visual Basic.
  5. Double-click CognosOfficeAutomationExample.bas in the Project pane to open it.
  6. Check for the following:
    Necessary API references
    1. m_oCOAutomation is defined as an object.
    2. m_oCAFE is defined as an object.
    3. There is a Property Get statement for CognosOfficeAutomationObject().
    4. There is a Property Get statement for Reporting().
  7. If you have all of the API references mentioned previously in your CognosOfficeAutomationExample.bas, you can start adding your own API functions. If you're missing one or more items, head over to https://ibm.github.io/paxapi/#necessary-ibm-cognos-automation-api-references and supplement the file with what you're missing.

Add your own API functions

You will choose different API functions depending on the tasks that you need to automate. Fortunately, there are plenty to choose from.

Procedure

  1. Right-click inside of the Project pane, click Insert > Module. This new module is where you will be adding your own API functions.
  2. Go to IBM Planning Analytics for Microsoft Excel API. This is where you can find IBM Cognos automation API functions.
  3. Click Exploration API functions.
  4. Click Create. This Create API function allows you to generate Exploration Views from a combination of host system URL, server name, cube name, and view name.
  5. Copy the example that is in this topic.
  6. Paste the example into the new module. You may have to adjust the formatting.
  7. Replace the example host system URL with the one that you are using.
  8. Replace Goal Input with Budget Input Total.
    Example of the Create API function.
  9. Save the template.

Results

You have just added your first API function! Next you'll be executing this API function.

Execute your API functions

Now that you have your API function added, it's time to execute them.

Procedure

  1. Click the DEVELOPER tab.
  2. Click Macros.
  3. Click Create.
  4. Click Run.
    Example of the Create API function.

Results

Congratulations! You have just automated creating an Exploration View from a view. Create two more Exploration Views for a total of three. In each Exploration View, change the department to sales, marketing, or engineering. Once you have one of each, go ahead and send those reports out to your manager. Task accomplished (and mostly automated).