I am trying to automate reports with the scripting language in BO 4.1.x.
In the scripts I create, I use [Application.Interactive = False] to stop the dialog windows and [On Error GoTo ErrorTrap] to trap errors.
When a report runs this way, if it encounters an error in the .Refresh method, an error code 2013 is returned by “Err”. How do I collect the actual BO error? If BO reports an error of 21007, how do I retrieve that in my script?
=====
Also, a report with parameter prompts runs fine, manually and scripted with .Interactive = True. If I set .Interactive = False, the .Refresh method sets Err to 2013. Why does it error off with .Interactive = False?
And again, how do I find out the BO error that caused the script error 2013?
Sample script:
Sub main()
Dim rpt As BOReport
Dim var As BOVariable
Dim PrintJob As String
Dim MsgText As String
Application.Interactive = False
On Error GoTo ErrorTrap
PrintJob = “BusinessObjects - PRFCT.001”
Application.Window.Caption = PrintJob & “: Loading Report Definition…” Application.Documents.Open(“k:\reports\bus_objs\562098.rep”)
Application.Window.Caption = PrintJob & “: Setting Parameters…” Set Var = Application.Variables.Add(“01 Master Account:”) Var.Value = “057980500”
Set Var = Application.Variables.Add(“02 Beginning
Date:”) Var.Value = “01/01/2000”
Set Var = Application.Variables.Add(“03 Ending
Date:”) Var.Value = “03/31/2000”
Set Var = Application.Variables.Add(“First Day of Last Month:”) Var.Value = “03/01/2000”
Application.Window.Caption = PrintJob & “: Running Report…” Application.Documents.Item(“562098”).Refresh
Application.Window.Caption = PrintJob & “: Exporting Report…” Set rpt = activedocument.reports.Item(1) rpt.ExportAsText(“k:\reports\bus_objs\562098.txt”)
Application.Window.Caption = PrintJob & “: Unloading Report…” Application.Documents.Item(“562098”).Close
NormalDone:
Application.Window.Caption = PrintJob & “: Done. - [562098.rep]” Open “k:\reports\bus_objs\562098.don” for Output as #1 Write #1, “Report is done.”
Write #1, MsgText
Close #1
AbnormalDone:
Application.Interactive = True
Application.Quit
Exit Sub
ErrorTrap:
MsgText = “Error#” & Err & " in script@" & Erl & ": " & Error$ '& " " & RefreshResult Application.Window.Caption = PrintJob & ": " & MsgText If Err = 2013 Then Resume Next
Open “k:\reports\bus_objs\562098.err” for Output as #1 Write #1, MsgText
Close #1
Resume AbnormalDone
End Sub
John Crowe
Data Warehouse Access
Listserv Archives (BOB member since 2002-06-25)