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!

Error Trapping in Macro 1

Status
Not open for further replies.

DrSimon

IS-IT--Management
Dec 14, 2001
674
GB
I have a macro which runs a list of reports whose names are held in a flat file, this macro is then scheduled so it normally runs in the background.
I have error trapping built into the macro (see below) but I have recently noticed that it has been hanging. By running in the foreground I have found that one of the reports is giving a Query Server Error where detail shows:[blue]
Error number -9:
DMS-E-GENERAL, A general exception has occurred during operation 'asynchronous open'. [/blue]

My code is: [green]
on error resume next
set impRep = impApp.OpenReport(Report_File,Prompt_String)
b_error=err
if err<>0 then
Print #1, "Error: " & Err & " " & Error$
else
Print #1, "Report opened: " & Report_File
end if [/green]
where #1 is a log file and b_error a temporary variable to hold err.

I ran the macro in debug, yet while the error message appeared, err did not get set (b_err=0).
I did not not write the report in question and unless the error relates to the macro, I'm not worried about the error itself - I just want to know how to trap such an error so I can log it and loop onto the next report in the list. Any ideas please?
Thanks in advance (hopefully)
Simon Rouse
 
Simon,
Are you running Impromptu as visible? Cognos KB article 115349 (Oct 2002 regarding 7.0) confirms the inability of cognos to trap DB errors, but appears to claim that if Impromptu is not visible, then the macro will continue on the next line. If this is true, then one could use a GetDatavalue test to determine no record set result and hence a possible DB error.
regards,
lex

soi la, soi carre
 
Thanks Lex that's just what I needed. I do forget to look on the Cognos site, but's often so awkward to get to what you want.
Simon Rouse
 
Simon,
You're welcome; thanks for the star. I haven't checked to see whether setting visible = 0 precludes any 'SaveAs'/'Export' functionality.

I agree with you re:Cognos KB - probably requires a tip-sheet/FAQ to get the best out of it!

lex

soi la, soi carre
 
Visible = False had no adverse impact on the Saveas - I just called the macro from the foreground and it worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top