Hello Gurus,
Need a small help in concating the currentdate timestamp in mdc file whenever my cube is built.
i am using a macro. please advise how this can be done?
for ex: In my model i have defined the cube name as salescube.mdc
after the cube is created i want to change th name to salescube_22012007 09:11:06 AM.mdc
how do i achieve this? Tried using the following:
"salescube" & "_" & format(Now,"ddmmyyyy hh:mm:ss AM/PM") & ".mdc"
but how do i make it work?
please reply asap.
thanks in advance.
regards,
aman
An example from a Cognos macro script:
timeStamp = Format(Now,"yyyymmddhhnn")
newfilename = sCubePubPath & sModelFilename & timeStamp & sCubeExtn
where sCubePubPath is the folder in which the file resides, sModelFileName is the filename without an extension, and sCubeExtn is the filename extension, i.e. ".mdc".
Thanks a lot. will try and update you the result.
Regards,
Aman
Hi Blue,
I believe th new file code works fine,but i am unable to copy the cube and see the new cube with changed filename too. A runtime error of R-70,PERMISSION DENIED comes.
My macro is mentioned in this mail. Basically i want a cube with new name(timestamp) to be generated in a new folder.
Sub Main ()
Dim objTransApp As Object
Dim objModel As Object
Dim strModelPath As String
Dim strLocation As String
Dim strModelSource As String
' *** File Names and Path(s) *****************************************************
strLocation = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Model\Monthly_Sales\"
strModelSource = "SalesModel.pyi"
strModelPath = strLocation & strModelSource
'*** Open model inside Transformer**********************************************
Set objTransApp = CreateObject("CognosTransformer.Application.cer4")
Set objModel = objTransApp.OpenModel(strModelPath)
'*** Clean model and build cubes************************************************
With objModel
.CreateMDCFiles
.Close
End With
' *** Copy the Cubes to the destination
Dim strCubePath As String
' *** Destination Folders*******************************************************
Dim strCognosFolder As String
' *** Cube Names***************************************************************
Dim strCube As String
' *** Set Source Folder Path***************************************************
strCubePath = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Cubes\"
' *** Set Destination Folder Path(s)*******************************************
strCognosFolder = "C:\Documents and Settings\tcbtr\Desktop\Cognos\Refresh_Cube\"
' *** Set Cube Names*************************************************************
strCube = "salescube.mdc"
Dim timestamp,sCubeExtn,newStrCube as String
timeStamp = format(Now,"ddmmyyyy hh:mm:ss AM/PM")
sCubeExtn = ".mdc"
newStrCube = "salescube"
Dim newFileName as String
newFileName = strCubePath & newStrCube & timeStamp & sCubeExtn
' *** Copy Each Cube into the Destination Folders*********************************
FileCopy strCubePath & strCube, strCognosFolder & newFileName
objModel.Close
Set objCube = Nothing
Set objTransApp = Nothing
Set objModel = Nothing
MsgBox "Refreshed Sales Cube has been created"
End Sub
please reply at the earliest. error is thrown at file copy
thanks in advance
regards,
aman
Hi all,
I was able to resolve this issue and update my cube name.
Thanks and Regards,
Aman
Techieman. You ask for help from people on the list but you don't offer anything in return! If you were able to resolve the issue then it behooves you to share how you resolved it with others on this forum!