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.
SystemAdmin 110000D4XK658 Posts
Re: CAM Namespace and API2012-10-02T23:52:01ZThis is the accepted answer. This is the accepted answer.Hi 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:18ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
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:11ZThis is the accepted answer. This is the accepted answer.
- Pindu 270005QPGG
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 Posts
Re: CAM Namespace and API2012-10-03T13:01:27ZThis is the accepted answer. This is the accepted answer.
- Pindu 270005QPGG
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.
Re: CAM Namespace and API2012-10-06T09:47:24ZThis is the accepted answer. This is the accepted answer.
- Mike_Cowie 270001XJHE
Got it working in the end.
Turns out it gives you the same error even if you get the server name wrong, doh! Had a typo.