Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why should I use a macro??

Status
Not open for further replies.

MiRRo

IS-IT--Management
Mar 21, 2003
54
NL
Hi,

I have build 5 cubes and over 40 reports. I use impromptu only for iqd's and we dont use upfront. I think its now the time for me to learn writing macro's. Here is my question. Can some one tell me why I should use a macro and what is the best way to learn writing macro's.

Thx!

Cheers,

MiRRo
 
MiRRo,
Macros would be useful to you if you need to change your iqds - usually for date reasons - on a regular basis. It can also allow you to use the same model to build different cubes - eg larger builds over weekends.
The added benefit is interaction with other applications. You mention reports. A macro is a good way of distributing reports to your users via email. You can also build in variations according to conditions - if a quarter has ended, the distribution of reports may be greater.
In summary, macros can remove a lot of the manual element of cognos work.

You can schedule using the cognos scheduler or call them from windows. There's been some debate here about which is better.

Starting? I don't know of a specific book, but the format and syntax are much like Visual Basic, so a borrowed VB book may assist. The help file of CognosScript is full of examples and there are some example scripts in the installation that are worth deconstructing. If you're logical, it's not too difficult - it's how I managed with no VB background. After all, you're smart enough to be using Cognos, so it should be a breeze.

HTH
lex
 
Hi drlex,

I am now interested in macros for my reports, like you said a macro for distrubuting reports is interesting. What kind of posibilities can be there still particularly for my reports? Because I am new for macros its a little bit difficult for me to imagine the posibilities. If it is not too much asked maybe you can give me a macro so I can begin with my learning process.

Thx in advance!

Cheers,

MiRRo
 
MiRRo,
Am more than happy to help. Since my macros aren't very compact, I'd better not post them on this site. Either post a spam-filtered/web email address here or send it to me at lexwatson@hotmail.com and I'll email back an example or two in the text of a reply.

As to reports, a macro can automate the saving of a report in HTML or Excel format. If the latter, I then call Excel to tidy up the formatting prior to sending it on.

W.R.T. mail, I use SMTP mail on our cognos server to send email to our MS Exchange server, as Exchange blocks application calls to send mail as an anti-spam measure. If you have a non-current version of Exchange or another mail application, check out other mailing threads on this site.

lex
 
Hi Lex,

Thx for your macro's but it is not so easy as I thought. If we take the macro about custom exceptions that you wrote for Cognos11 as example. My first question.
- I have an report named Segmentanalyse.ppr so I should think the macro has to be like this. Where do I have to fill my report preferences more.
Thanks!
MiRRo
Sub Main()
Dim PPRep As Object
Dim PPRow As Object
Dim PPColumn As Object

Set PPRep = GetObject (, "Segmentanalyse.ppr")
PPRep.ExplorerMode = False

Set PPRow = PPRep.Rows.Active
Set PPColumn = PPRep.Columns.Active
If (PPColumn is Nothing) then
PPRow.Style = "Good News"
ElseIf (PPRow is Nothing) then
PPColumn.Style = "Good News"
Else
MsgBox "Please select row or column"
End If
Set PPRow = Nothing
Set PPColumn = Nothing
Set PPRep = Nothing
 
MiRRo,
Most of the macros I use are called by Cognos Scheduler, so that cube builds, report generations and Impromptu reports can be run out of hours.
The Macro you've quoted is designed to be called from within PowerPlay Client by a user and it just puts either a selected row or selected column into the style called "Good News"
The Line
Set PPRep = GetObject(, "CognosPowerPlay.Report")
picks up the active report and makes it an object for further commands.
I'm not sure what you mean by "report preferences" - can you give an example of what you're trying to do in a macro and then it can be considered in stages.
lex


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top