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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add an icon on PP toolbar that will execute cube refresh macro 1

Status
Not open for further replies.

MerIT

Technical User
Jun 2, 2003
11
PL
Hi - Sorry for repeating my question. I have forgotten to write subject yesterday.

Does anybody have idea how to write a macro that will close the opened cube - update the cube and open the PowerPlay Client again with refreshed report.
I would like to add the button for this macro to PowerPlay toolbar.

Is it possible?
Regards
Gregory
 
ok, I found in PP user help how to to set up a Launch Button - find below. Could anyone drop few lines how to refresh current cube?

"You can add up to 64 launch buttons to a custom toolbar. You can configure each button to run a
different program or macro.
For example, you are the manager of a government department. You keep the data source files
for your reports in Microsoft Excel spreadsheets. While reviewing your reports, you want to look
at your data source files. You customize your toolbar to run Excel directly from PowerPlay,
Impromptu, or Transformer.
Steps
1. From the Tools menu, click Customize.
2. Click the Toolbar Buttons tab.
3. In the Category box, click Miscellaneous.
The buttons in the Miscellaneous category appear in the Available Buttons box.
4. Click Toolbar Launch Button, and drag it to a toolbar.
5. Double-click the new launch button.
The New Launch Item dialog box appears.
6. In the Name box, type a name for the launch button.
7. In the Description box, type a brief description of what the button does.
The tooltip appears when you pause the pointer over the button.
8. In the Type box, click Macro or Application.
9. In the Command box, browse to the location of the macro or program.
10. In the Parameters box, enter any parameters you want to add to the macro or program.
11. If you want to minimize the current window when you run the program or macro, select the
Minimize Application Before Launching check box.
12. In the Image box, click the image you want to appear on the new launch button.
13. In the Path box, browse to the location of the button image.
14. Click OK.
Tip: To change the settings of a launch button, ensure the Customize dialog box is closed, and
Ctrl+click the launch button and then make changes in the Modify Launch Item dialog box."
 
Hi, uff...I managed to write some code, I had 3 years experience in Cognos, last one in Business Objects and now again in my beloved Cognos :) but ... for what I can say about programming in Cognos compared to BO it is that CognosScript has not changed for ages and in my opinion is POS (hope I don't have to decode it) commpared to VBA functionallity in BO. Who trired to create anything that is of average in complexivity can say that: even creating some GUI in Cognos Script with 10 or so forms will take tons of time instead of minutes.

So I have what I wanted: I have an icon on PowerPlay toolbar that executes cube refresh (saves report path and name to memory, closes ppr report, refreshes cube and opens my report). Below is beta-code. I still work on delay with MsgBox (for when executing macro it doesn't wait for shell programs' finish, thats why msg box trick there (first reason) and I want the user to see msg after finished cube update (second reason).

I will want the macro to recognise PYI path, so it could be UNIVERSAL method of any PPR raport cube refresh no mater what cube is it based on. I realize this is not the thing that the Cognos/BI admin would like to share with all PPusers but in some cases (fe. Admin) it is the great thing? Isn't it :))))

If you got any ideas how to solve dalay and PYI 'case' - please let me know ... I'm going to dig some more manuals, KB for that :)))

Gregory
grzegorz@olap.pl




Declare Sub delay(slow as double)
Sub delay(slow as double)
dim x as double, y as double
x = timer
do
y = timer
loop until y > x + slow
End Sub

Sub Main()

Dim objPPRep as Object
Dim objPPRep2 as Object
Dim strPPRepPath as String
Dim strPPRepName as String
Dim strTrsfrmrPath as String
Dim strPYIPath as String
Dim batch as integer

Set objPPRep = GetObject( ,"CognosPowerPlay.Report")
strPPRepPath = objPPRep.Path
strPPRepName = objPPRep.Name

' *** Paths to Transformer and PYI cube model
' *** Wpisz sciezki do Transformer'a i modeli kostek PYI
strTrsfrmrPath = "C:\Program Files\Cognos\cer3\bin\trnsfrmr.exe"
strPYIPath = "D:\Workdir\Outdoors.pyi"

objPPRep.Close
batch = Shell(strTrsfrmrPath+" -n -s "+strPYIPath)

delay(4) '- this will delay for n seconds to wait with below MsgBox
MSGBox "The PowerPlay cube was updated successfully. The name of the current report is: " & objPPRep.Name &". Report is based " & "on the following cube:" & chr$(10) & chr$(10) & objPPRep.CubeName, , "PowerPlay Cube"

Set objPPRep2 = CreateObject("CognosPowerPlay.Report")
objPPRep2.Open strPPRepPath & strPPRepName &".ppr"
objPPRep2.Visible = 1
Set objPPRep = Nothing
Set objPPRep2 = Nothing
Set objPPApp = Nothing

End Sub

 
It is possible to add a procedure that will check transformer windows process execution state ... and it works :)
grzegorz@olap.pl
 
ok , here it is ... so the macro starts with:

Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long

Const NORMAL_PRIORITY_CLASS = &H20&
Const INFINITE = -1&

Sub ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO

' Initialize the STARTUPINFO structure:
start.cb = Len(start)

' Start the shelled application:
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
End Sub

Sub Main ()

....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top