I have created an Excel VB-based dependency checker that shows which cubes are related to which processes and rules and another process which shows which dimensions are related to which cubes, processes and rules. The idea is that it can highlight which dimensions are redundent and identify which objects need to be updated if you want to change or delete an object.
Here is the vb process that populates the dependencies for cubes (data directory needs to be updated before running):
Code: Select all
Sub Cube_to_ProRux()
ReDim strCubeArray(1 To 200)
ReDim strCubesArray(1 To 200, 1 To 4, 1 To 200)
Dim StrSorted()
i = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
'##################### Update Server Directory Accordingly ############################
directory = "\\server\d$\Cognos\TM1 Servers\data\"
'Create cube array
Set F = FSO.getFolder(directory)
Set ff = F.Files
'Cells(1, 4) = Now
For Each f1 In ff
If f1.Type = "CUB File" Then
strCubeArray(i) = Left(f1.Name, Len(f1.Name) - 4)
strCubesArray(i, 1, 1) = Left(f1.Name, Len(f1.Name) - 4)
'Cells(i, 1) = Left(f1.Name, Len(f1.Name) - 4)
strCubesArray(i, 2, 1) = "Process Refences"
strCubesArray(i, 3, 1) = "Rule Refences"
i = i + 1
End If
Next
Set TextStream = Nothing
Set ff = Nothing
Set FSO = Nothing
Set F = Nothing
i = i - 1
ReDim Preserve strCubeArray(1 To i)
'Search pro files for cube references
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F = FSO.getFolder(directory)
Set ff = F.Files
For Each f1 In ff
Select Case f1.Type
'##################### PRO File ############################
Case "PRO File"
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
strline = TextStream.readall
For i = 1 To UBound(strCubeArray)
If (InStr(strline, strCubeArray(i)) > 0) Then
For j = 2 To UBound(strCubesArray)
If strCubesArray(i, 2, j) = "" Then
strCubesArray(i, 2, j) = Left(f1.Name, Len(f1.Name) - 4)
Exit For
End If
Next
End If
Next
Set TextStream = Nothing
'##################### RUX file ############################
Case "RUX File"
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
strline = TextStream.readall
For i = 1 To UBound(strCubeArray)
If (InStr(strline, strCubeArray(i)) > 0) Then
For j = 2 To UBound(strCubesArray)
If strCubesArray(i, 3, j) = "" Then
strCubesArray(i, 3, j) = Left(f1.Name, Len(f1.Name) - 4)
Exit For
End If
Next
End If
Next
Set TextStream = Nothing
End Select
Next
Set TextStream = Nothing
Set ff = Nothing
Set FSO = Nothing
Set F = Nothing
'Populate array
x = 1
For i = 1 To UBound(strCubeArray)
Cells(x, 1) = strCubeArray(i)
Cells(x, 1).Font.Bold = True
If (strCubesArray(i, 2, 2) & strCubesArray(i, 3, 2) = "") Then
x = x + 1
Else
For j = 2 To 3
If (strCubesArray(i, j, 2) <> "") Then
st = x + 1
k = 1
While (strCubesArray(i, j, k) <> "")
Cells(x, 2) = strCubesArray(i, j, k)
If (k = 1) Then
Cells(x, 2).Font.Underline = xlUnderlineStyleSingle
End If
k = k + 1
x = x + 1
Wend
Range("A" & st & ":A" & x - 1).Select
Selection.Rows.Group
End If
Next
End If
Next
End Sub
Code: Select all
Sub Dim_to_Cube()
ReDim strCubeArray(1 To 200)
ReDim strCubesArray(1 To 200, 1 To 4, 1 To 200)
Dim StrSorted()
i = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
'##################### Update Server Directory Accordingly ############################
directory = "\\server\d$\Cognos\TM1 Servers\data\"
'Create cube array
Set F = FSO.getFolder(directory)
Set ff = F.Files
For Each f1 In ff
If f1.Type = "DIM File" Then
strCubeArray(i) = Left(f1.Name, Len(f1.Name) - 4)
strCubesArray(i, 1, 1) = Left(f1.Name, Len(f1.Name) - 4)
i = i + 1
End If
Next
Set TextStream = Nothing
Set ff = Nothing
Set FSO = Nothing
Set F = Nothing
i = i - 1
ReDim Preserve strCubeArray(1 To i)
'Search pro files for cube references
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F = FSO.getFolder(directory)
Set ff = F.Files
For Each f1 In ff
Select Case f1.Type
'##################### CUB File ############################
Case "CUB File"
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
For k = 1 To 5
If (TextStream.AtEndOfStream) Then
Exit For
End If
strline = TextStream.readline
For i = 1 To UBound(strCubeArray)
strCubesArray(i, 2, 1) = "Cube Refs"
If (InStr(strline, strCubeArray(i)) > 0) Then
For j = 2 To UBound(strCubesArray)
If strCubesArray(i, 2, j) = "" Then
strCubesArray(i, 2, j) = Left(f1.Name, Len(f1.Name) - 4)
Exit For
End If
Next
End If
Next
Next
'##################### PRO File ############################
Case "PRO File"
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
strline = TextStream.readall
For i = 1 To UBound(strCubeArray)
strCubesArray(i, 3, 1) = "Process Refs"
If (InStr(strline, strCubeArray(i)) > 0) Then
For j = 2 To UBound(strCubesArray)
If strCubesArray(i, 3, j) = "" Then
strCubesArray(i, 3, j) = Left(f1.Name, Len(f1.Name) - 4)
Exit For
End If
Next
End If
Next
Set TextStream = Nothing
'##################### RUX file ############################
Case "RUX File"
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
strline = TextStream.readall
For i = 1 To UBound(strCubeArray)
strCubesArray(i, 4, 1) = "Rule Refs"
If (InStr(strline, strCubeArray(i)) > 0) Then
For j = 2 To UBound(strCubesArray)
If strCubesArray(i, 4, j) = "" Then
strCubesArray(i, 4, j) = Left(f1.Name, Len(f1.Name) - 4)
Exit For
End If
Next
End If
Next
Set TextStream = Nothing
End Select
Next
Set TextStream = Nothing
Set ff = Nothing
Set FSO = Nothing
Set F = Nothing
'Populate array
x = 1
For i = 1 To UBound(strCubeArray)
Cells(x, 1) = strCubeArray(i)
Cells(x, 1).Font.Bold = True
If (strCubesArray(i, 2, 2) & strCubesArray(i, 3, 2) & strCubesArray(i, 4, 2) = "") Then
x = x + 1
Else
For j = 2 To 4
If (strCubesArray(i, j, 2) <> "") Then
st = x + 1
k = 1
While (strCubesArray(i, j, k) <> "")
Cells(x, 2) = strCubesArray(i, j, k)
If (k = 1) Then
Cells(x, 2).Font.Underline = xlUnderlineStyleSingle
End If
k = k + 1
x = x + 1
Wend
Range("A" & st & ":A" & x - 1).Select
Selection.Rows.Group
End If
Next
End If
Next
End Sub
Set TextStream = FSO.OpenTextFile(directory & f1.Name, 1, False, -2)
strline = TextStream.readline
I have tried ?strline to debug the problem cube and it outputs very differetly to what working cubes and the physical cube contains.
Ie. "?strline =
01,100
562,"SUBSET"
586,"}clients"
585,"}clients""
"
but the first line of the physical cube is:
"x
exchange_type version
from_currency to_currency"
"
I am at a loss as to why it outputs differently, and I thought it would consistently work (or fail). Does anyone have any ideas why its not reading the file correctly? I have tried different types of encrytion on the vb side (unicode etc) but I thought all TM1 cube files would be encoded and read the same. Im using 9.52 and pre as well as post unicode cubes work.
thanks in advance
Gareth