Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2012-10-06T09:47:24Z by Pindu
Pindu
Pindu
4 Posts
ACCEPTED ANSWER

Pinned topic CAM Namespace and API

‏2012-10-02T16:43:51Z |
Hi,

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
Sub LogOn()
Dim sstring As String * 255, hCamArray As Long
TM1APIInitialize
hUser = TM1SystemOpen()

TM1SystemAdminHostSet hUser, cstrAdminHost

pGeneral = TM1ValPoolCreate(hUser)
hCamArray = PopTM1Array(cstrNameSpace, cstrClient, cstrPwd)
hServer = TM1SystemServerConnectWithCAMNamespace(pGeneral, TM1ValString(pGeneral, cstrServer, Len(cstrServer)), _
hCamArray)
***** Crashes on line above ******

TM1SystemClose (hUser)
TM1APIFinalize

End Sub
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)))
End If
TM1ValArraySet hArray, hValue, x + 1
Next x

PopTM1Array = hArray
End Function

Any assitance greatly appreciated.

Thanks,
Pindu
Updated on 2012-10-06T09:47:24Z at 2012-10-06T09:47:24Z by Pindu
  • SystemAdmin
    SystemAdmin
    658 Posts
    ACCEPTED ANSWER

    Re: CAM Namespace and API

    ‏2012-10-02T23:52:01Z  in response to Pindu
    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.

    Rod
    • Pindu
      Pindu
      4 Posts
      ACCEPTED ANSWER

      Re: CAM Namespace and API

      ‏2012-10-03T08:15:18Z  in response to SystemAdmin
      Thanks 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?

      Cheers,
      Pindu
      • Pindu
        Pindu
        4 Posts
        ACCEPTED ANSWER

        Re: CAM Namespace and API

        ‏2012-10-03T08:33:11Z  in response to Pindu
        OK, 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
          Mike_Cowie
          3 Posts
          ACCEPTED ANSWER

          Re: CAM Namespace and API

          ‏2012-10-03T13:01:27Z  in response to Pindu
          Hi:

          One thing you should know about this API function is that if you get this error message when attempting a CAMNamespace login:
          SystemServerClientNotFound

          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.

          Regards,
          Mike
          • Pindu
            Pindu
            4 Posts
            ACCEPTED ANSWER

            Re: CAM Namespace and API

            ‏2012-10-06T09:47:24Z  in response to Mike_Cowie
            Cheers Mike,

            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.