Page 1 of 1

Alias of an Element

Posted: Thu Feb 04, 2010 6:19 pm
by samuvk
Hi All,

Everything is going much easier now, thanks to all you guys, but I'm still have questions and problems.

I'm trying to get the Alias of an element in a Dimension.

Trying to use this code:

Code: Select all

  Dim Element As String
  Dim l_DimIdx As Long
  Dim Alias As String

  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx, Alias)
If for instance I have a Element named Co.52 which Alias is "A Bank" I'm getting in Alement Co.52 and I'm trying to get "A Bank".

Thank you for all your help again

Re: Alias of an Element

Posted: Thu Feb 04, 2010 8:11 pm
by Mike Cowie
Hi:

Try using the DBRA TM1 function to get the alias:

Code: Select all

  Dim Element As String
  Dim AliasAttributeName As String
  Dim AliasValue As String
  Dim l_DimIdx As Long

  AliasAttributeName = "<Your Alias Name Goes Here>"
  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx)
  AliasValue = Application.Run("DBRA", Server & ":" & Dimension, Element, AliasAttributeName)

Hope that helps!

Regards,
Mike

Re: Alias of an Element

Posted: Thu Feb 04, 2010 8:13 pm
by Alan Kirk
samuvk wrote: I'm trying to get the Alias of an element in a Dimension.

Trying to use this code:

Code: Select all

  Dim Element As String
  Dim l_DimIdx As Long
  Dim Alias As String

  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx, Alias)
If for instance I have a Element named Co.52 which Alias is "A Bank" I'm getting in Alement Co.52 and I'm trying to get "A Bank".
There are several problems there.

The first is that while DimNm can return an alias, that isn't its primary role. DimNm is for when you need to specify the position number (index) of an element in a dimension, and want to get the name of the element that's in that position. DimNm will return that name, optionally using an alias.

The code that you have above will always return the name of first element in the dimension, regardless of which one that is.

The second problem is that you haven't populated the Alias string variable with the name of the alias that you want. That means that you'll be passing an empty string to the last argument of DimNm, and that means that you'll just be getting the base name of the element (presumably "Co.52") as you described.

If all you want is the alias, and you want to specify the element that you want the alias for, you may as well use DBRA instead of DimNm:

Code: Select all

Sub AliasDisplay(Server As String, Dimension As String)

Dim s_ElementBaseName As String
Dim s_ElementAlias As String
Dim s_Alias As String

'You'd more likely pass this as a further argument.
s_ElementBaseName = "Co.52"

'You need to specify which alias you want rteturned; let's
'suppose that the alias is called "Desc".
s_Alias = "Desc"

s_ElementAlias = Application.Run("DBRA", _
 Server & ":" & Dimension, s_ElementBaseName, s_Alias)

MsgBox s_ElementAlias

End Sub
Edit: Ooops, Mike beat me to it...