cancel
Showing results for 
Search instead for 
Did you mean: 

How do you propagate changes to child tables?

Former Member
0 Kudos

With Parent/Child relationships, I'd like all changes to my parent table's id to be propagated to the child table's FK.  Mostly, if I create the FK between parent1 and child1 and then later I tag the PK of parent1 as a particular domain, how do I get the child's domain to match?

1) How do I have PD do this by default?

2) How do I ask PD to make sure this happens for any and all FK relationships that exist already?

Accepted Solutions (0)

Answers (1)

Answers (1)

GeorgeMcGeachie
Active Contributor
0 Kudos

Check the Model Options for your PDM. In the Reference section, there is an option to migrate domain links to FK columns.

I found I had to disable this option, then re-enable it get domains to migrate. Domains are only migrating when a reference is created, not when I change the domain in the parent column. I also found that propagation of changes to the parent column's data type is more widespread if the data type is changed via a table symbol on a diagram, rather than via the column's property sheet. Any data types that aren't changed should be flagged by a model check, and you can run the auto-correction to fix them.

I hope SAP are monitoring this conversation .

There isn't a built-in mechanism that I can find to migrate domain links from parent to child columns. A script to do this is fairly simple. I created this just now as a Method for Columns. It could also be implemented as a model check.

Sub %Method%(obj)

   ' Implement your method on <obj> here

   if not obj.foreignkey then ' not FK

      exit sub

   end if

 

   dim FKJoin

   for each FKJoin in obj.ForeignKeyJoins

     

      FKJoin.RefreshJoin()

     

      if FKJoin.ParentTableColumn.Domain is nothing then ' parent column has no domain

         output "Parent column for " & obj & " has no domain"

         exit for

      end if

     

      if FKJoin.ParentTableColumn.Domain = obj.Domain then ' same domain

         output "Domains match for " & obj

      else

         set obj.Domain = FKJoin.ParentTableColumn.Domain

         output " changed Domian for " & obj & " to match domain on " & FKJoin.ParentTableColumn.DisplayName

      end if

   next ' FK Join

End Sub

GeorgeMcGeachie
Active Contributor
0 Kudos

There was a typo and an omission in the script. This one is better (it removes the domain from the FK column if the parent column has no domain).

Sub %Method%(obj)

   ' Implement your method on <obj> here

   if not obj.foreignkey then ' not FK

      exit sub

   end if

 

   dim FKJoin

   for each FKJoin in obj.ForeignKeyJoins

     

      FKJoin.RefreshJoin()

     

      if FKJoin.ParentTableColumn.Domain is nothing then ' parent column has no domain

         output "Parent column for " & obj & " has no domain"

         obj.Domain = Nothing

         exit for

      end if

     

      if FKJoin.ParentTableColumn.Domain = obj.Domain then ' same domain

         output "Domains match for " & obj

      else

         set obj.Domain = FKJoin.ParentTableColumn.Domain

         output " changed Domain for " & obj & " to match domain on " & FKJoin.ParentTableColumn.DisplayName

      end if

   next ' FK Join

End Sub

GeorgeMcGeachie
Active Contributor
0 Kudos

Now I've slept on it, I think it would be better for the script to process all the reference joins in a model or package, making sure that ChildTableColumn matches ParentTableColumn where required. This script would be a right-click menu item for the model or package, and could also be run as part of a Transformation. A Custom Model Check for columns would also be helpful.