cancel
Showing results for 
Search instead for 
Did you mean: 

Powerdesigner: Create calculated collection based on attribute

11-25-2024 12:47 PM
RWZI Discoverer
510 views 1 comments
0 Likes
SAP Managed Tags
Labels
Calculated collectionpowerdesigner
Subscribe

Hi all,

This seems like kind of a basic question, but I haven't been able to find a whole lot about calculated collections.

I'm trying to create a calculated collection of objects in SAP PowerDesigner, so I can use this pre-filtered set of entities in my report. The problem is: I can't get the syntax right. The best result I've gotten so far (in the report) is a number of lists containing one entity each instead of one list containing every entity. In the dependencies tab, only one entity (the entity whose property window is open) is visible. 

This is the code I used:

Function %Collection%(obj, coll)
   If obj.GetAttribute("Stereotype") = "Relatie" Then
   coll.Add obj
   End if
   %Collection% = True
   
End Function

Can the calculated collection be used as a pre-defined filter for entities (so only entities with the stereotype "Relatie" are in it)?

 

Thanks in advance

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

Ondrej_Divis
Contributor

Hi,

if your goal is just filtering entities (based on Stereotype value) in your report, you don`t need calculated collections at all. You can use filtering options in your report editor. See attached screenshot.

Report_filter.png

If you (for whatever reason) still need calculated collection, then your problem is called the scope. If you define your collection at the model level (tab Dependencies in the model properties), you have to browse all your entities present in the model. So the code should look like:

 

Function %Collection%(obj, coll)
  Dim ent
  For each ent in obj.Entities
    coll.Add ent
  Next
  %Collection% = True
End Function

 

If you need to have this collection available on the Dependencies tab of every entity (i.e. Entity level) you have to define your calculated collection at Entity metaclass level and the code should look like this:

 

Function %Collection%(obj, coll)
   Dim ent
   For each ent in obj.Model.Entities
     coll.Add ent
   Next
   %Collection% = True
End Function

 

Perhaps you are looking for the Stereotype = "Relatie" condition. You don`t have to code it at all. You simple filter it on the General page of the Calculated collection. Right under the Target Type dropdown list, there is a Target Stereotype dropdown list. Put your stereotype in there and that`s it.

In case you need some more complex extensions/customizations of PowerDesigner, feel free to contact me on LinkedIn. I`ll be happy to help.

Regards,

Ondrej Divis