Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

scripting mapping between Physical data models

Hello!

I am looking at a script to create mappings within PowerDesigner. There is an example in the Help that looks like this:

'Create a mapping between C1 and T6 set m1 = ds.CreateMapping(MyOOM.FindChildByName("Class1",cls_class))

m1.AddSource MyPDM.FindChildByName("Table6",cls_table)

I have been able to make this work to achieve a mapping between tables in a Target Physical data model and a Source Physical data Model. However what I really want to do is map between columns - I have a spreadsheet with all the mappings defined and rather than manually create them one by one, I thought i could save time and script it (generating the code in Excel and then pasting into the execute window in PD).

I have not yet found any example for mapping by column (in Help or on the Internet) and am failing to get it to work.

I have used the CanCreateMapping() method and it shows a positive for a column object, but it then fails on the CreateMapping method.

HERE IS MY CODE:

dim ds1 : dim tab1 : dim m1: dim col1 : dim map1 : dim map2

'set the active model object

set m1 = ActiveModel

'set the source model object

Set m2 = OpenModel("C:\users\jfraser\my documents\freshfields\powerdesigner\SAP_Extracts.pdm")

'set the datasource object

set ds1 = m1.findchildbyname("SAP_Extract",PDPDM.cls_datasource)

'set the target table object

set tab1 = m1.FindChildByName("DM_ACTION",PDPDM.cls_table)

'output to screen (shows correct value)

output tab1.name

'set the target column object

set col1 = tab1.FindChildByName("DWH_ACTION_KEY",PDPDM.cls_column)

'output to screen (shows correct value)

output col1.name

'test the objects as valid for mapping (both show as true)

output ds1.cancreatemapping(tab1)

output ds1.cancreatemapping(col1)

'set the mapping objects

set map1 = ds1.CreateMapping(tab1)

set map2 = ds1.CreateMapping(tab1, col1)

' test the mapping objects (map1 is fine, map2 fails with "object doesn't support this property or method: 'name'")

output map1.name

output map2.name

any help, advice, corrections or comments are welcomed!

thanks

Tags:
Not what you were looking for? View more on this topic or Ask a question