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!

Cube automation

Status
Not open for further replies.

CognosTalk

Technical User
Apr 24, 2007
71
CA
I created a bat file to automate cube build; somehow it is not functioning properly. It is calling the transformer and dying after. signon and automatic login is enabled in the model.
Any thoughts?
 
Run the .bat file in a DOS box and see where it strands.
Make sure you checked syntax, cause this is a case of getting every expression just right!!
Are you using the cubeswap utility?

If not, then this is a sample we are using:

start "XXXXXX Cube" /w "c:\Program Files\Cognos\cer4\bin\trnsfrmr.exe" -n -s "c:\XXXXXX software\YYYYYYY\XXXXXXX\Modellen\Somemodel.pyi"

Ties Blom

 
Or use a batch file to call a CognosScript Macro to build the cube - can do more and log or email errors. For example:

a) build the cube in a temp area and only switch into "live" if built successfully

b) update iqds

c) change pyi file (date dimension)

d) trigger modification dates on reports in PPES

e) mail out xl versions of powerplay reports after successful build

soi là, soi carré
 
thank you very much for your respond!
my bat file is working now
with command
cogtr.exe -n2 -y1"namespace=username/password" -r4 "D:\Cognos\Transformer\Models\Sales_Revenue_Master.pyj"

why do i have to specify username/password if i already put one into the cube signon??
another question is i scheduled it using windows schedule and it does not run at all, but runs from the command like successfuly, what can be the problem????
 
Sure; this one opens a transformer file, changes a special date category to sum the months in the current calendar year (main dimension is May-April financial), builds the cube and then swaps it into the live area.
It logs timings and errors to a log file, plus emails on completion or error. (A job on SQL server reads the log file & stores daily performance data.)

Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Main()
   Dim objOutlookEmail as Object
   Dim objTransApp As Object
   Dim objModel As Object
   Dim objDimension As Object
   Dim objCategory As Object
   Dim strTo As String
   Dim strSubject As String
   Dim strBody As String
   Dim Logfile as string
   '
   Logfile = "E:\Logs\CognosLog.csv"
   Open Logfile For APPEND As #1
   Write #1, Format(DATE,"yyyy-MM-dd"),Format(Time,"HH:mm:ss"), "Stock Start"
   Close #1
   '
   On Error goto ErrMes 'If problem, email & then exit
   '
PART_I:  'Open and build cube
   Set objTransApp = CreateObject("CognosTransformer.Application")
   Set objModel = objTransApp.OpenModel("E:\PPModels\Stock.pyi","Administrator","Password","Root User Class")
   Set objDimension = objModel.Dimensions.Item("All Dates") 
   Set objCategory = objDimension.Categories(2)   
   With objCategory
   ' set current calendar year and include right months
     .Name = "Calendar Year" & str(year(Cvar(date)-1))
     .RunningPeriods = month(cvar(date)-1) 
     .Update
   End With
   With objModel
      .CreateMDCFiles
      .Update
      .SaveAs "E:\PPModels\Stock_Run.pyi" 
      .Close
   End With
   Set objDimension = Nothing
   Set objCategory = Nothing
   Set objModel = Nothing
   Set objTransApp = Nothing
   '
PART_II: 'Switch cube into live between stopping and starting PPES
   Shell ("E:\batch_files\kill_stock_cube.bat")   
   sleep 10000
   FileCopy "E:\cubes\Stock.mdc", "E:\Live_Cubes\stock.mdc" 
   sleep 10000
   Shell ("D:\batch_files\enable_stock_cube.bat")   
   '
PART_III:   'create and send email
   strSubject = "Stock cube"
   strBody = "Now built. This has been an automated message." 
   strTo = "lex.luthor@acme.com"
   Set objOutlookEmail = CreateObject("CDONTS.NewMail")
   with objOutlookEmail
      .From = "Cognos@Acme.com"
      .To = strTo
      .Subject = strSubject
      .Body = strBody
      .MailFormat = 0 
      .Send
   End with
   set objOutlookEmail = nothing
   '
endmac:
   Open Logfile For Append As #1
   Write #1, Format(DATE,"yyyy-MM-dd"),Format(Time,"HH:mm:ss"), "Stock End"
   Close #1   
Exit Sub
   '
ErrMes:
   strTo = "lex.luthor@Acme.com"
   strSubject = "Stock macro FAILURE"
   strBody = "Please note that the cube build failed with error " & Err & " : " & Error$ & " which occurred at line: " & Erl
   If weekday(CVar(DATE))=1 or weekday(CVar(DATE))=7 then strSubject = strSubject + " at the weekend"
   '
   Set objOutlookEmail = CreateObject("CDONTS.NewMail")
   with objOutlookEmail
      .To = strTo
      .From = "Doomsayer@Acme.com"
      .Subject = strSubject
      .Body = strBody
      .MailFormat = 0
      .Send
   End with
   set objOutlookEmail = nothing
   Open Logfile For Append As #1
   Write #1, Format(DATE,"yyyy-MM-dd"),Format(Time,"HH:mm:ss"), "Error " & Err & " @ line: " & Erl & " - " & Error$ 
   Close #1
   Resume endmac
End Sub

The batch files referenced by the 'Shell' command are to start and stop the cubes in PowerPlay Enterprise Server, in case they are in use at the time of update. They use the CLI offered by ppadmtool.exe.

soi là, soi carré
 
Thank you for sharing the macro; i did not have a chance to build one yet, but using my small bat file to schedule the cube. I am scheduling it using windows schedule, it works, but i do not want to schedule it on the weekend, how can i set it up? i did not see any setting in windows scheduler that allow me to skip execution on the weekends.
i guess it should be a part of the .bat file?
How can i set it up??
Thank you in advance,
MK.
 
Start>Settings>Control Panel>Scheduled Tasks. Right-Click required task, choose Properties - "Schedule" tab & set to Weekly. Tick all weekdays.
Simples!

soi là, soi carré
 
Thank you very much!! i was not even thinking to look at the weekly, i used daily..
 
Hi,
I am currently experiencing a problem with windows scheduler, I have scheduled a DTS job that truncates data and then builds a cube off that data via a batch file within the DTS process.

The truncate part works fine, however the PowerPlay Transformer hangs. I have scheduled a batch file to build another works great. I an ensured that no transformer sessions are open at time of build. Extract from the log.

LogFileDirectory=\\xxxxxx\cognos\cubes\logs
ModelSaveDirectory=\\xxxxxx\cognos\cubes\models\
DataSourceDirectory=d:\business reporting\iqds\
CubeSaveDirectory=\\xxxxxx\cognos\cubes\building site\
DataWorkDirectory=\\xxxxxx\cognos\cubes\temporary files\data1\
ModelWorkDirectory=\\xxxxxx\cognos\cubes\temporary files\model\
MaxTransactionNum=25000000
ReadCacheSize=65536
WriteCacheSize=65536
Temporary UDA directory=D:\Business Reporting\Temporary Files\Impromptu Temp

I have run the content of the batch from the command prompt; runs fine.

I have launched the batch file manually; works fine.

I have ran the DTS job manually; works fine.

Just when I automate it on windows 2000.
I am stomped at this..any suggestions would be great.

Batch File content : "C:\Program Files\Cognos\cer3\bin\trnsfrmr.exe" -n2 -s "\\xxxxx\cognos\Cubes\Models\Cube 166 (xxxxxx).pyi"

 
When you are automating it, is the Windows log-on for automation different to that used when running the jobs manually?
Could be a permissions issue related to log-on, either windows file or pyi model security (should it or the data sources have such).

P.S. Forum etiquette is that you start your own thread.

soi là, soi carré
 
Hi

Permissions has nothing to do with it.

As I can automate other builds successfully.

No security on the cube.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top