cancel
Showing results for 
Search instead for 
Did you mean: 

Powerdesigner searching for an entity by GUID in VBA

data-arch-100
Explorer
0 Kudos
373

Hello,

I have a script I run in powerdesigner that loops through all entity symbols and colours bases on a fundamental area, assigned in the extended attributes. 

I have now started to use packages, I use entities from the main Enterprise data model to construct specific business area models, with very few specific business area entities. However, these entities are shortcuts, and they are called 'Shortcut of entity' when outputting the symbol class. 

The issue I am facing is that the shortcut symbols do not house the Extended attributes and as such the script cannot colour appropriately. However they do have the same GUID as the 'non-shortcut' symbols.

I was thinking I can loop though on the GUID to find the symbol with a value extended attribute value and use this variable to color the shortcut symbols. Is there a search function I can use to pull entitys/symbols with a specific GUID ? I could loop through the whole model looking for the GUID's but this seems a big unessassery workaround. 

Any help would be very much appriciated.

Many thanks

SAP PowerDesigner

View Entire Topic
Ondrej_Divis
Contributor

Hi,

If I understood it correctly, you need to colour the symbol of entity shortcut and you need to colour it according to the extended attribute values of its original entity. In that case you can just use the TargetObject property of a Shortcut, which will lead you to the "original" entity object and then you can access its extended attribute. So no looping necessary. Does this answer your question?

Regards,

Ondrej Divis

GeorgeMcGeachie
Active Contributor
0 Kudos
Once upon a time in the past. you could only access properties via a shortcut if the target model was open, but that changed ages ago. Now you can see the property values as at the last time the two models were open at the the same time. If you've checked the model out of the repository, they should also be up to date.
data-arch-100
Explorer
0 Kudos
Yes that is exactly what I am trying to do, how do you know there is a TargetObject property ? When looking through the 'SAP PowerDesigner Metamodel Objects help.' I cannot find shortcut symbols in there.
GeorgeMcGeachie
Active Contributor
You can find shortcut properties in Libraries | PdCommon | Shortcut
Ondrej_Divis
Contributor
0 Kudos
EntitySymbol doesn`t have TargetObject property. EntitySymbol has Object property, which will lead you to the object itself, which could be either "full" Entity or Shortcut of Entity. And if it is Shortcut of Entity, you can use its TargetObject property to get to the full Entity.
data-arch-100
Explorer
0 Kudos

I have tried but can seem to get it to work Below is a portion of the script in the formatting:

sub FormatEntity(s)
dim ExAttName
dim FundamentalSA
dim EntityClass
dim FillColour
dim boolFormatEntity
dim o
set o = s.Object

output "############## FormatEntity ##############"
output o
output o.ClassKind
output o.ClassName

dim test1
dim test1object
dim test2

test1 = o.TargetObject
output "test1 " & test1
test1object = test1.object
test2 = test1object.GetExtendedAttributeText(ExAttName)
output "test2 " & test2

Output statements: 

### Symbol : Agreement of ClassKind= -2044982537 ClassName= Entity Symbol
############## FormatEntity ##############
Shortcut of entity 'Agreement'
908935660
Shortcut of entity
test1 Entity 'Agreement'

 

I get an error:

dataarch100_0-1723645253065.png

 

GeorgeMcGeachie
Active Contributor
0 Kudos
Take a look at some of the standard scripts, such as "C:\Program Files\SAP\PowerDesigner 16\VB Scripts\List Tables.vbs"
Ondrej_Divis
Contributor
0 Kudos

Hi, two things. You should use Set command to assign objects to your variables: Set test1 = s.Object (instead of wrong test1 = s.Object). And second, make sure, that the model containing original entity object is opened. Otherwise PD cannot access it to read the values of your extended attributes. Regards, Ondrej

Ondrej_Divis
Contributor
P.S. This new discussion forum kind of sucks... You cannot make new paragraphs in your reactions, you cannot post screenshots... You can do all of that in separate answer, but these answers cannot be posted as reaction to specific previous post... I hope SAP will work on that soon...
data-arch-100
Explorer
0 Kudos
I cant believe it, what a miss ! I even have it correct a few lines above ! Thank you Ondrej you have been a massive help, Do you use Powerdesigner regularly ?
Ondrej_Divis
Contributor
Good to hear. Actually yes, I have been customizing, extending, troubleshooting and giving PowerDesigner traninings full time for the last 16 years. So in case you are interested in some more complex extension / scripting in PowerDesigner or any kind of PD training, feel free to contact me. That is what I do. You can send me direct message here or you can find me on LinkedIn. Have a nice day. Ondrej.
GeorgeMcGeachie
Active Contributor
0 Kudos
I used to do what Ondrej does but was not as successful at drumming up business 😞