API: TM1SystemOpen function in VWD 2005 Express

Post Reply
jimshen
Posts: 13
Joined: Tue Jan 20, 2009 11:50 pm

API: TM1SystemOpen function in VWD 2005 Express

Post by jimshen »

Hi all,

I found the function TM1SystenOpen getting too many digits which might be the cause for the error "Attempted to read or write protected memory". It gives me 19 digits rather than 9 in normal.

The error stopped at the statement vUserName = TM1ValString(pPoolHandle, sUser, vStingLength)

Anybody can help me to get the solution?

Regards

Jim
shockwave
Posts: 88
Joined: Mon Dec 15, 2008 10:45 am
OLAP Product: TM1
Version: 9.1.3
Excel Version: 2003 SP3

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by shockwave »

Hey mate,

Wish i could help you out. But am curious as to how you got TM1 working within the VWD environment. I have been using basic ado to run MDX queries to populate asp.net tables, but have not been able to connect to TM1 and access the processes and adomd.net. I have added the "Applix.TM1.API" namespace but dont appear to able to get it to work + access the TM1 objects. Not sure whether you've been able to connect but if you have do you have some code handy to allow users to run processes via a command button??

Cheers

Shock
User avatar
Mike Cowie
Site Admin
Posts: 482
Joined: Sun May 11, 2008 7:07 pm
OLAP Product: IBM TM1/PA, SSAS, and more
Version: Anything thru 11.x
Excel Version: 2003 - Office 365
Location: Alabama, USA
Contact:

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by Mike Cowie »

jimshen wrote:Hi all,

I found the function TM1SystenOpen getting too many digits which might be the cause for the error "Attempted to read or write protected memory". It gives me 19 digits rather than 9 in normal.

The error stopped at the statement vUserName = TM1ValString(pPoolHandle, sUser, vStingLength)

Anybody can help me to get the solution?

Regards

Jim
Hi Jim,

Can you provide some additional details about things like:
  • Your TM1 Version
  • A sampling of the TM1 API declarations being used
  • A sampling of the TM1 code and variable declarations you are using
TM1SystemOpen returns a handle that is a long integer, and that may ultimately not be a number that is always 9 digits. It is possible that something else is causing the TM1ValString call to fail.

Regards,
Mike
Mike Cowie
QueBIT Consulting, LLC

Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
User avatar
George Regateiro
MVP
Posts: 326
Joined: Fri May 16, 2008 3:35 pm
OLAP Product: TM1
Version: 10.1.1
Excel Version: 2007 SP3
Location: Tampa FL USA

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by George Regateiro »

shockwave wrote:Hey mate,

Wish i could help you out. But am curious as to how you got TM1 working within the VWD environment. I have been using basic ado to run MDX queries to populate asp.net tables, but have not been able to connect to TM1 and access the processes and adomd.net. I have added the "Applix.TM1.API" namespace but dont appear to able to get it to work + access the TM1 objects. Not sure whether you've been able to connect but if you have do you have some code handy to allow users to run processes via a command button??

Cheers

Shock

I dont know how far along you are in .NET coding, but the basics of what you are trying to do can be accomplished by the following steps. I have not coded this outright, this is by using the API intelisense so dont expect a copy and paste result.


1) Create an instance of the TM1AdminServer object;
2) Create the TM1Server object by using the <Adminserver from step 1>.Servers[<servername>].Login(<credentials>)
3) Then something along the lines of the <TM1Server from step 2>.Processes[<processname>].Execute(<parameters>)


I have started on a class that I will post out the code/utilities forum that further simplifies the tm1 .net API, once I think it is in good enough order.

But the basics to the .Net API are Create a TM1AdminServer object, Create the TM1Server from the login function of the TM1AdminServer and then see what options the intelisense gives you from there. Also pay close attention to the tool tip and return types, they will help you out. Unfortunately without better docs from TM1 the .NET API is a lot of trial and error till you find what you are looking for.
shockwave
Posts: 88
Joined: Mon Dec 15, 2008 10:45 am
OLAP Product: TM1
Version: 9.1.3
Excel Version: 2003 SP3

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by shockwave »

Thanks George, for the tips. Going to give it try once I get back in the office next week to test it out.

Cheers

Shock
jimshen
Posts: 13
Joined: Tue Jan 20, 2009 11:50 pm

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by jimshen »

Mike Cowie wrote:
jimshen wrote:Hi all,

I found the function TM1SystenOpen getting too many digits which might be the cause for the error "Attempted to read or write protected memory". It gives me 19 digits rather than 9 in normal.

The error stopped at the statement vUserName = TM1ValString(pPoolHandle, sUser, vStingLength)

Anybody can help me to get the solution?

Regards

Jim
Hi Jim,

Can you provide some additional details about things like:
  • Your TM1 Version
  • A sampling of the TM1 API declarations being used
  • A sampling of the TM1 code and variable declarations you are using
TM1SystemOpen returns a handle that is a long integer, and that may ultimately not be a number that is always 9 digits. It is possible that something else is causing the TM1ValString call to fail.

Regards,
Mike
Hi Mike,

[*]The TM1 version is 9.1 SP2.
[*]API Declaration I used are:
Inherits System.Web.UI.Page
Public db As ADODB.Connection
'Const sCube As String = "Sales_Dept"
Const sServer As String = "Dev"
Const sUser As String = "JShen"
Const sPass As String = ""
Dim col() As String

Public hUser As Long
Public pGeneral As Long
Public voDatabase As Long
Declare Sub TM1APIInitialize Lib "tm1api.dll" ()
Declare Function TM1SystemOpen Lib "tm1api.dll" () As Long
Declare Function TM1ValPoolCreate Lib "tm1api.dll" (ByVal hUser As Long) As Long
Declare Sub TM1SystemAdminHostSet Lib "tm1api.dll" (ByVal hUser As Long, ByVal AdminHosts As String)
Declare Function TM1ValIndex Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitIndex As Long) As Long
Declare Function TM1ValString Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitString As String, ByVal MaxSize As Long) As Long
Declare Function TM1SystemServerConnect Lib "tm1api.dll" (ByVal hPool As Long, ByVal sServer As Long, ByVal sClient As Long, ByVal sPassword As Long) As Long
Declare Function TM1SystemServerDisconnect Lib "tm1api.dll" (ByVal hPool As Long, ByVal hServer As Long) As Long
Declare Sub TM1ValPoolDestroy Lib "tm1api.dll" (ByVal hPool As Long)
Declare Sub TM1SystemClose Lib "tm1api.dll" (ByVal hUser As Long)
Declare Sub TM1APIFinalize Lib "tm1api.dll" ()

[*] The sampling of the TM1 code and variable declarations I am using[/list]:
Dim sAdminHost As String = "BI-TM1-SERVER"
Dim pPoolHandle As Long
Dim vPassword, vServerName, vUserName As Long
Dim vServerHandle, vResult As Long
Dim vStringLength As Long

TM1APIInitialize()
hUser = TM1SystemOpen
TM1SystemAdminHostSet(hUser, sAdminHost)
pPoolHandle = TM1ValPoolCreate(hUser)

'vStringLength = TM1ValIndex(pPoolHandle, 10)
vStringLength = Left(pPoolHandle, 10)
vUserName = TM1ValString(pPoolHandle, sUser, vStringLength)
vPassword = TM1ValString(pPoolHandle, sPass, vStringLength)
vServerName = TM1ValString(pPoolHandle, sServer, vStringLength)


The interesting thing is that same codes in VBA (MS Acess) work fine with same TM1 server. It suggests me the problem should be TM1 and VB.Net. Not sure can have some way walk around it ?

Regards

Jim
shockwave
Posts: 88
Joined: Mon Dec 15, 2008 10:45 am
OLAP Product: TM1
Version: 9.1.3
Excel Version: 2003 SP3

Re: API: TM1SystemOpen function in VWD 2005 Express

Post by shockwave »

Hey George,

Tried adding in the library files to reference tm1api.dll but no luck. When I go to run my code I get the following error: "Unable to load DLL 'tm1api.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

I am running this on my xp window client using VWD2005. The only files I can reference are:

Applix.TM1.API.dll
Applix.TM1.API.SSLNetSock.dll
Applix.TM1.API.SSPI.dll

The TM1 installation is in D:\Program Files\Cognos\bin

I have noticed that from the notes it mentions to install the following components in this order

• TM1LIB.dll
• TM1SIP.dll
• TM1API.dll

I can see these bin files in D:\Program Files\Cognos\bin, but when I go to "add a reference" it says "a reference to 'D\progam files\cognos\bin\tm1p.dll" could not be added"

Any ideas and why this would be happening?? Am I doing this correctly? Totally lost - NFI. BTW I am doing this on my local machine and not on the server, which really shouldn't make a diff.

Cheers

Shock
Post Reply