Paul,
It is possible - the CognosScript command objImpRep.GetDatavalue(x,y) will return the value in a list report at column x of row y. A few points to bear in mind:
1) retrieve the information prior
2) x is determined by the SQL sent to the database, so count from the Query data list in Report>Query. Similarly y is determined by any sort/group you have.
3) a null report will generate an error for the command.
Alternatively, always generate the Excel report and use the macro to read the values in the Excel sheet to determine subsequent actions.
You're welcome; waiting for a couple of jobs to finish, so can't start anything new. Just to re-iterate, I've only used this on list reports; cross-tabs and forms may well require more consideration of what x & y should be.
I tend to end up doing a lot of "post-production" in Excel, so feel free to ask Qs on that too...
I did try the getdatavalue but we have null values in the report so it won't work (like you said).
I am looking at the export excel option at this time, but in this case, can Cognos script check excel as well or do we have to write a VBA macro in Excel?
Just found an earlier reply from you in a thread which said that you can use almost any Excel VBA command in Cognos. Tryed a little and I am almost there, just have to put in some actions in an if then statement.
Paul,
It would appear that most of the Excel VBA commands can be used in CognosScript. I have found a work around for those that do not - basically adding a macro to the workbook to perform the actions, executing it and then removing it prior to saving the file. Tedious, but effective.
To speed things up, keep Excel invisible, turn off both the alerts (to allow over-writing of the file) and the screen refresh:
objExcel.Application.DisplayAlerts = False
objExcel.Application.ScreenUpdating = False
You'll also either need to convert Excel constants to integers or try and include an Excel constants file like that for Transformer ("TRANSCONST.INC") found in the install location ...\cer5\data\samples\PowerPlay\Macros\
On Error Resume Next
ObjImpRep.ExportExcelWithFormat LocExp & "Checkdataset Before Export.xls"
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.DisplayAlerts = False
objExcel.Application.ScreenUpdating = False
ObjExcel.Application.Workbooks.Open LocExp & "Checkdataset Before Export.xls"
If objExcel.Sheets("Checkdataset Before Export").Range("A2") = Null Then
msgBox "RUN MACRO"
Else
msgBox "DO NOT MACRO"
End If
Paul,
Cognosscript doesn't understand null. If I were checking, I'd read the value of A2 using FormulaR1C1 and then test that.
If objExcel.Sheets("Checkdataset Before Export").Range("A2").FormulaR1C1 = "" then ...
I should have said that, whilst objImpRep.GetDatavalue(x,y)will throw an error if the cell referenced is Null, you can always use 'ON ERROR RESUME NEXT' prior to the line so as to cause the macro to ignore it and then test for a nil (zero or blank string, depending on the definition of the variable).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.