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!

CognosScript code to return Current Month Value

Status
Not open for further replies.

Jjinks

Programmer
Mar 6, 2003
3
GB
In a macro I want to get the value of the "Current Month" this is a category in the All Years dimension of a cube (not neccesarily the current month I run the macro).

Example:

If the cube was run in March 03 then the "Current Month" value would be "Feb/2003", this is the value I want to get.

Any ideas.

Thanks
 
Jjinks, there's a script command "CurrentPeriod" which does exactly what you want.
TGIF,
lex

Try the following:
Sub Main ()

Dim Curdate as string
Dim objTransApp As Object
Dim objModel As Object
Dim objDateDim As Object
Dim objDateLevel As Object
Dim strLocation As String
Dim strModelSource As String
Dim strModelPath As String
strLocation = "K:\PPModels\" 'where you keep your models
strModelSource = "Test.pyi" ' model name and type
strModelPath = strLocation & strModelSource

Set objTransApp = CreateObject("CognosTransformer.Application")

Set objModel = objTransApp.OpenModel(strModelPath)
Set objDateDim = objModel.Dimensions("All dates") 'must match your date dimension label
Curdate = objDateDim.CurrentPeriod.Name

MsgBox "Current Period:" + Curdate

'prob. good practise to save model but up to you!

Set objDateLevel = Nothing
Set objDateDim = Nothing
Set objModel = Nothing
Set objTransApp = Nothing

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top