I'm trying to write some code in VB to simply check if my TM1 Server is still 'up'.
The only thing i'm trying to do is connect to the server, and simply get a value out of a simple cube with two dimensions.
For some reason, after reading trough the API guide, and related topics on this forum, I can't seem to get my code to work.
My returned value always keeps on saying '6' which is an error code I suppose
The connection seems to run alright, but when I start 'querying' the cube with the 'TM1CubeCellValueGet' function,
I can't seem to read the return value correctly.
I think it has something to do with my array-container which doesn't seem to fill up as it should,
but i really don't know how to debug it....
Can anyone take a look at my code, or provide me with some working code to answer a simple query of a cube value via the API ?
info cube = Vessel List
dim 1 = 'vessels'
dim 2 = 'measures vessels'
This is my code :
Private Sub cmdgetcubevalue_Click()
Dim sServerName As String
Dim sUsername As String
Dim sPassword As String
Dim hUserHandle As Long
Dim pPoolHandle As Long
Dim vPassword, vServerName, vUserName As Long
Dim vStringLength As Long
Dim RetVal As String * 75
TM1APIInitialize
hUser = TM1SystemOpen()
TM1SystemAdminHostSet hUser, "myadminserver"
pPoolHandle = TM1ValPoolCreate(hUser)
vStringLength = TM1ValIndex(pPoolHandle, 10)
vUserName = TM1ValString(pPoolHandle, "Myuser", vStringLength)
vPassword = TM1ValString(pPoolHandle, "", vStringLength)
vServerName = TM1ValString(pPoolHandle, "myserver", vStringLength)
vServerHandle = TM1SystemServerConnect(pPoolHandle, vServerName, vUserName, vPassword)
'Start the cube querying
Dim vessel As String
Dim measure As String
vessel = "BB"
measure = "Volume"
Dim hvessel As Long
Dim vvessel As Long
Dim hmeasure As Long
Dim vmeasure As Long
ReDim elementArray(2) As Long
hvessel = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Vessels", 0))
vvessel = TM1ObjectListHandleByNameGet(pPoolHandle, hvessel, TM1DimensionElements(), TM1ValString(pPoolHandle, vesel, 0))
hmeasure = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Measures Vessels", 0))
vmeasure = TM1ObjectListHandleByNameGet(pPoolHandle, hmeasure, TM1DimensionElements(), TM1ValString(pPoolHandle, measure, 0))
elementArray(1) = vvessel
elementArray(2) = vmeasure
Dim elementArrayCapsule As Long
elementArrayCapsule = TM1ValArray(pPoolHandle, elementArray, 2)
'set the array values
Call TM1ValArraySet(elementArrayCapsule, elementArray(1), 1)
Call TM1ValArraySet(elementArrayCapsule, elementArray(2), 2)
'create cube handle.
hCubeObject = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerCubes(), TM1ValString(pPoolHandle, "Vessel List", 0))
Dim Value As Variant
Value = TM1CubeCellValueGet(pPoolHandle, hCubeObject, elementArrayCapsule)
' This doesn't work
MsgBox TM1ValType(hUser, Value)
' This doesn't work either
Value2 = TM1ValIndexGet(hUser, Value)
MsgBox (Value2)
'Log Out
vResult = TM1SystemServerDisconnect(pPoolHandle, vServerName)
TM1ValPoolDestroy (pPoolHandle)
TM1SystemClose hUser
TM1APIFinalize
End Sub
I would much appreciate an answer , cause after a day of searching I still end up with a diabolic





Regards,
Tom