Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member200945
Contributor
0 Kudos

Recently I got a question from several clients.

The question is how to pass extended attribute value when convert from, for example, LDM to PDM.

In this post, I'll demonstrate using Powerdesigner transformation to fulfil the goal.

The model project.ldm (contains the extension) and pdm extension are attached at end of the article.

To use the files, download and unzip them. remove .txt .

I am on powerdesigner 16.5.5.

In project.ldm, I create an extension with an extended attribute called ALIAS for each entity.

I assign alias for each entity:

Entity name                                                      Alias

      Activity                                                        ACT

      Compose                                                    COMP

      Customer                                                    CUST

      Division                                                       DIV

      Employee                                                   EMP

      Material                                                      MAT

      Member                                                      MEMB

      Participate                                                  PART

      Project                                                        PRJ

      Task                                                           TSK

      Team                                                          TM

      Used                                                           U

I have two goals:

A)  Pass the extended attribute and its value to PDM

B)  Restore the extended attribute in PDM.

     Use alias to build foreign key constraint in PDM.

A) Let's create a new extension.

    a) In Workspace, right click the model and select New->Extension

  b)  Right click Profile and select Add Metaclasses...

        Since the extended attribute in LDM is defined in Entity level, I must check Entity. Click OK.

   

  c)  An object called Entity is created. Right click Entity. Select New->Transformation.

 

  d) Hight the transformation. Click Transformation Script. Add the following code:

      obj.annotation = obj.getExtendedAttribute("ALIAS")

      What the code does is to store alias in entity's annotation field.

  e) Click top item and select Add Items.

 

  f) Check Transformation Profiles. Click OK.

   

  g)  Click TransformationProfiles. Select New.  Profile_1 is created.

h) Highlight Profile_1 and click Pre-generation tab. Click Add Transformations icon.

i) Check the transformation we have created. Click OK.

 

j)  Right click Entity and go to New->Extended Attribute. Set name to ALIAS, data type to String

   

k) Now you can assign alias for each entity in project.ldm.  Create your own alias or use mine.

l)  Go to Tools->Generate Physical Data Model. We want to generate a new PDM

   

m)  Click Detail tab. Click Enable transformations button.

      Now you should see Pre-generation tab shows up. Check the transformation we just created. Click OK

   

n)   Once the process end, go to the PDM, double click a table to bring up its property. Click Definition tab. Click Annotation tab.

      The alias value is in there.

   

We have successfully passed alias value to PDM.

The key idea of this approach is that  we want to find a temporary place to store a value.  And

1) this temporary place can be passed to other type of model.

2) this temporary place can be easily modified.

3) we can easily find the owner of the temporary place.

4) our extended attribute and the temporary place has the same owner.

Clearly an object's comment, description, annotation field match above conditions.

If these fields have already had value in it, you can add your value at beginning or end of the string, using unique delimiter.

Later on you can extract the value based on the delimiter.

Example:

In Annotation field, there is string called "this is test". You can put alias "ACT" at end of the string using format:

      this is test>!>!>!<!<!<!<ACT

B)  Now let's restore alias for PDM.   Open the PDM you just generated from LDM.

a) Create a new extension

b) Create an extended attribute called ALIAS in Table. Set its data type to String.


c) Right click Table and select New->Transformation.

    Add the following code:

      obj.setExtendedAttribute "ALIAS", obj.annotation

   

d) Create transformation profile.  Create a post-generation.  For detail step see screenshot above in LDM section.

e) Save the change.  Go to Tools->Apply Transformations. Check the transformation you just created. Click OK

     

      Now all aliases are restored.

       

The next thing we want to do is create a transformation to build foreign key constrain using the alias.

In the PDM, go to Model->References.  The original FK constraint name is very complicated.

Our goal is use format

           Alias of child table_Alias of parent table_FK

to replace the existing ones.

All you need do is create a post-generation in object model. Write vbscript

I attach my extension file in the post.

You can import it  by create a new Extension or open existing one, clicking ExtendedDefinition_1, clicking the import items icon.

To export an extension, click Save icon.

This is how my extension looks like:

Now go to Tools->Apply Transformations.  Select your transformation. Click OK.

 

This is the final result:


If you modify the LDM or its extension and want to apply the change, you can do the following:

Make sure both LDM and PDM are in the workspace. Bring up LDM's diagram.

Go to Tools->Generate Physical Data Model

Select Update existing Physical Data Model. In Detail tab, click Enable transformations button

You 'll see both Pre-generation and Post-generation tab. Check proper transformations in both tabs.

Click OK.

Finally, you need clear the temporary place. In our example, it's the annotation field of the Table object.

Using previous example, you want to extract

this is a test

from

this is a test<!<!<!<!>!>!>!>ACT

Write vbscript using  function split and replace.

If the temporary place merely has alias, you simply reset the field to empty.

1 Comment