If you are unable to create a new account, please email bspsoftware@techdata.com

Author Topic: concating date-timestamp in the mdc file  (Read 10899 times)

techieaman

  • Guest
concating date-timestamp in the mdc file
« on: 22 Jan 2007 09:08:20 am »
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

Offline Blue

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jul 2005
  • Posts: 281
  • Forum Citizenship: +15/-0
  • The earth is one country ... Baha'i Faith
Re: concating date-timestamp in the mdc file
« Reply #1 on: 22 Jan 2007 12:41:58 pm »
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".
Robert Edis
Principal
Robert Edis Consulting
Rotorua, New Zealand

techieaman

  • Guest
Re: concating date-timestamp in the mdc file
« Reply #2 on: 22 Jan 2007 01:30:26 pm »
Thanks a lot. will try and update you the result.

Regards,

Aman

techieaman

  • Guest
Re: concating date-timestamp in the mdc file
« Reply #3 on: 22 Jan 2007 01:55:55 pm »
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.

Code: [Select]

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

techieaman

  • Guest
Re: concating date-timestamp in the mdc file
« Reply #4 on: 25 Jan 2007 11:21:45 am »
Hi all,

I was able to resolve this issue and update my cube name.

Thanks and Regards,

Aman

Offline Blue

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jul 2005
  • Posts: 281
  • Forum Citizenship: +15/-0
  • The earth is one country ... Baha'i Faith
Re: concating date-timestamp in the mdc file
« Reply #5 on: 19 Dec 2008 05:08:50 pm »
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!
Robert Edis
Principal
Robert Edis Consulting
Rotorua, New Zealand