TM1 API how to get value stored in TM1valobject

Post Reply
kpradeep25
Posts: 18
Joined: Mon May 09, 2011 3:09 pm
OLAP Product: TM1
Version: 9.4
Excel Version: EXCEL 2003

TM1 API how to get value stored in TM1valobject

Post by kpradeep25 »

hi,

I am trying to get NAME attribute of the control dimension "}Groups" . In order to do that I first get that value stored in the object handler as below

' -- handler to ger dimesnion object
grpDimesnion = TM1ObjectListHandleByNameGet(pPoolHandle, vServerhandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "}Groups", 0))

'-- handler object to store element
Dimelement = TM1ObjectListHandleByNameGet(pPoolHandle, grpDimesnion, TM1DimensionElements(), TM1ValString(pPoolHandle, "ADMIN", 0))

'--handler object to store attribute value
vAttrval = TM1ObjectListHandleByNameGet(pPoolHandle, Dimelement, TM1ObjectAttributes(), TM1ValString(pPoolHandle, "NAME", 0))
If TM1ValTypeObject = TM1ValType(SessionHandle, vAttrval) Then
MsgBox CInt(TM1ValTypeObject)
End If

--now calling procedure to retrieve string value of attribute
Call TM1ValObjectGet(SessionHandle, vAttrval, pobject) --> this throw the error

But this throws below runtime error which hangs excel client including TM1 perspective.

"Runtime error -'2147417848'
Automation error
The object invoked has disconnected from its client"

Any idea what is wrong here?
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: TM1 API how to get value stored in TM1valobject

Post by tomok »

kpradeep25 wrote:But this throws below runtime error which hangs excel client including TM1 perspective.
If you are using VBA in Excel, with an active Perspective session, why on earth are you using the TM1 API???????? There are plenty of TM1 macros, as well as all the native Excel functions you can call with an Application.Run that make programming in VBA light years easier then writing anything with the API.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
User avatar
Mike Cowie
Site Admin
Posts: 483
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: TM1 API how to get value stored in TM1valobject

Post by Mike Cowie »

I agree with Tomok's point here - if this is just your own TM1 API curiosity then that's one thing, but if you're really trying to do all this work when you can instead call TM1 Excel functions from VBA/Excel (like DBRA), then you're making a simple problem extremely complex. I guess I'd forgotten in your previous thread that you were going down the path of doing all this in VBA - I can understand why you'd have to use the API for the CAM login (because N_CONNECT doesn't support a Cognos Security login), but beyond that there aren't too many reasons to use the TM1 API from VBA, with the possible exception of running TI processes or chores and there are many examples of that around here on the forum.

With reservations noted above by Tomok and I, your API problem is that your vAttrval is a handle to the element attribute in the }Groups dimension. It is not the attribute value, it's a handle to the element attribute object. You need to use that with the handle to your element in the TM1ObjectAttributeValueGet function to get the actual attribute value for the element:

But, again, why work so hard when you have TM1USER, DBRA and other TM1 functions that you can call from VBA instead of a hundred API calls to get the same thing. Doesn't this look much easier (if you have to do this in VBA instead of Excel)?:

Code: Select all

AttrValue = Application.Run("DBRA", "YourServerName:}Groups", "ADMIN", "NAME")
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!
kpradeep25
Posts: 18
Joined: Mon May 09, 2011 3:09 pm
OLAP Product: TM1
Version: 9.4
Excel Version: EXCEL 2003

Re: TM1 API how to get value stored in TM1valobject

Post by kpradeep25 »

Thanks Tom, I am now exploring excel macro functions which appears to be much easier than API. But there are some tasks which excel macro can not perform such as autheticating against cam security using single login screen.
Post Reply