Srcipting questions

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)

I think it is something todo with the date format. When a dialox box is popped up for Prompts and you enter value for date prompt, BO converts it to proper format. But when you set the variable thru’ script (in BO4) it’s always considered as string, there is no conversion involved. What I mean is, the final SQL sent to your database should contain the dates in proper format.

Then how is it working in .Interactive=true mode and with script. Because in this mode, though you assign value for prompt variables, BO displays a dialog box with the string you have assigned to those variables and when you press OK, it converts it to proper date format.

Set Var = Application.Variables.Add(“02 Beginning
Date:”) Var.Value = “01/01/2000”

Use proper date format, in the second line. For example,
var.value = “01/01/2000 00:00:00”

you can try with different formats. If you want to find the format used your BO, look at \DataAccess<YourDatabase>*.sbo

This file has a parameter called InputDateFormat. Set your date variable in this format.Look at BO data access guide for your database for more info.

Hope it helps
Vasan

jcrowe@COMPUCOM.COM on 04/17/2000 05:38:35 PM

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?

******************************************************************************* Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Ernst & Young LLP



Listserv Archives (BOB member since 2002-06-25)