Trying to connect to TM1 using VBA API without the addin loaded. Security mode is set at 5 so using cam security.
Not sure what I'm doing wrong but it keeps on crashing my excel when running TM1SystemServerConnectWithCAMNamespace. Code below:
Const cstrAdminHost As String = "AdminHost"
Const cstrServer As String = "Prod"
Const cstrNameSpace As String = "Space", cstrClient As String = "MyClient", cstrPwd As String = "MyPwd"
Dim hUser As Long, hServer As Long, pGeneral As Long
Dim sstring As String * 255, hCamArray As Long
hUser = TM1SystemOpen()
TM1SystemAdminHostSet hUser, cstrAdminHost
pGeneral = TM1ValPoolCreate(hUser)
hCamArray = PopTM1Array(cstrNameSpace, cstrClient, cstrPwd)
hServer = TM1SystemServerConnectWithCAMNamespace(pGeneral, TM1ValString(pGeneral, cstrServer, Len(cstrServer)), _
***** Crashes on line above ******
Function PopTM1Array(ParamArray vValues()) As Long
Dim hArray As Long, lArray() As Long, i As Long, x As Long, hValue As Long
Dim sstring As String * 255
i = UBound(vValues)
ReDim lArray(i + 1)
hArray = TM1ValArray(pGeneral, lArray(), i + 1)
For x = 0 To UBound(vValues)
If VarType(vValues(x)) = vbString Then
hValue = TM1ValString(pGeneral, vValues(x), Len(vValues(x)))
ElseIf VarType(vValues(x)) = vbDouble Then
hValue = TM1ValReal(pGeneral, CDbl(vValues(x)))
TM1ValArraySet hArray, hValue, x + 1
PopTM1Array = hArray
Any assitance greatly appreciated.
This topic has been locked.
5 replies Latest Post - 2012-10-06T09:47:24Z by Pindu
Pinned topic CAM Namespace and API
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-10-06T09:47:24Z at 2012-10-06T09:47:24Z by Pindu
SystemAdmin 110000D4XK658 PostsACCEPTED ANSWER
Re: CAM Namespace and API2012-10-02T23:52:01Z in response to PinduHi Pindu,
From my limited experience with the API your code looks fine, perhaps it is the declaration of the function.
For reference this is the declaration I have:
Declare Function TM1SystemServerConnectWithCAMNamespace Lib "tm1api.dll" (ByVal hPool As Long, ByVal hServer As Long, ByVal hCAMArray As Long) As Long
Hope this helps.
Re: CAM Namespace and API2012-10-03T08:15:18Z in response to SystemAdminThanks Rod.
Yup, the declaration is the same.
I've checked that the array is created fine and the values of the array are all correct and present. Namespace name is correct, and user name exists on sever. Password is also correct.
I'm lost! Anyone from IBM on here that might be able to assist?
Re: CAM Namespace and API2012-10-03T08:33:11Z in response to PinduOK, had a minor light bulb moment and it now no longer crashes my excel. Solution to that was to declare my variables as strings with the same length.
Dim strServer As String * 255, strClient As String * 255, strPwd As String * 255
Although that has now fixed the crash issue, I cannot log on. Keep getting an error saying "SystemServerClientNotFound". I have tried every possible format of the client name but no luck!
Mike_Cowie 270001XJHE3 PostsACCEPTED ANSWER
Re: CAM Namespace and API2012-10-03T13:01:27Z in response to PinduHi:
One thing you should know about this API function is that if you get this error message when attempting a CAMNamespace login:
It could mean any one of the following problems:
- You entered in the wrong namespace name, or didn't use the proper case for the namespace.
- Your user ID does not exist.
- Your password is incorrect.
This is very confusing to say the least - the problem I most often run into is that the specified namespace is being correct. Unlike what you may be used to in TM1, the CAM Namespace argument is both case and space-sensitive. So, if your namespace is "Cognos" you'll get the above SystemServerClientNotFound error when using "COGNOS" or "cognos".
Hope that helps.