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

Newbie Cognos scripting 1

Status
Not open for further replies.

180881

Technical User
Apr 4, 2003
4
0
0
NL
I have a problem with Cognos scripting.
I am trying to export a report as txt file.
Using the standard script from the help file

Sub Main()
Dim objImpApp As Object
Dim objImpRep As Object
Dim strTextFileName As String
Set objImpApp = CreateObject("CognosImpromptu.Application")
Set objImpRep = objImpApp.ActiveDocument
strTextFileName = "test"
objImpRep.ExportText strTextFileName & ".csv"
Set objImpRep = Nothing
Set objImpApp = Nothing
End Sub

But when running the macro in the script editor I get the error:test!Main(8) - R91 "Object value is set to Nothing"

And in Cognosimprompt u error code: -1003

Does anybody know where this is coming from?
What am I doing wrong?
again I am a complete newbie

Thnx in advance
paul
 
Block these 2 lines and try
Set objImpRep = Nothing
Set objImpApp = Nothing

Prasad. Prasad
RPrasad1@Chn.Cognizant.com
 
Paul,
You don't say what version of Impromptu you're using, but in 7.0, the format I use is
objImpRep.Export strFileName & ".csv", "x_ascii.flt"
Might be worth a try
HTH
lex
 
Tryed both this solutions but they did not help thnx anyway.
We have version 7.0 of cognos.

still strange that a standard cognos script generates errors

 
Paul,
Does the script work if you
1) add a line to open the catalogue - e.g:
objImpApp.OpenCatalog "c:\catalogues\test.cat","Creator",,,,1

2) add a line to open the report - e.g.
Set objImpRep = objImpapp.OpenReport("c:\Reports\SalesDaily.imr)

and then run the script from the editor

It looks like you should run the script to save as text an open report, yet unless you were running Improptu in single instance mode, it would open a new session of Impromptu and therefore try to save nothing - hence the error?
lex
 
Thnx dr lex, last solution helped a bit.
But there is one problem when opening the specific report it gives a prompt for a date. I can only enter the date in the script.
Is it possible to run the macro with a prompt?


Or is this very difficult
 
Paul,
no it's a snap, just add a comma and the prompt within the open report line.
If the date is required in a certain format, then format a string to your requirements. Here's an extract from one of mine that puts the date 12m ago in as a prompt and saves the amended iqd.

Dim startdate
Dim strstartdate as string
Dim strstartprompt as string
Dim objImpApp As object
Dim objImpRep As Object
Dim objTransApp As Object
'
startdate = CVar(Date-365)
strstartdate = CStr(startdate)
strstartprompt = Format(strstartdate,"yyyy-mm-dd")
'
'PART I
'Open Impromptu Report and export as iqd for cube
Set objImpApp = CreateObject("CognosImpromptu.Application")
objImpApp.Visible 1
objImpApp.OpenCatalog "c:\catalogues\test.cat","Creator",,,,1
Set objImpRep = objImpApp.OpenReport ("c:\Reports\12m Sales prompted.imr",strstartprompt)
Set objImpRep = objImpApp.ActiveDocument
objImpRep.Export "c:\iqd\12mSales.iqd", "x_iqd.flt"
'close Impromptu and release objects
objImpRep.CloseReport
objImpApp.Quit
Set objImpRep = Nothing
Set objImpApp = Nothing

HTH
lex
 
Are you using windows 2000 with Impromptu 7.0? I'm getting an "ActiveX can't create object" error on the following line

Set objImpApp = CreateObject("CognosImpromptu.Application")

...Chargrams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top