cancel
Showing results for 
Search instead for 
Did you mean: 

powerdesigner : Assign domains to data items

Former Member
0 Kudos

Hi,

I have a requirement where i want to assign a <Dummy> domain to all the data items which have <undefined> data type and <undefined> domain; in a conceptual data model (CDM)

The number of such fields is huge, hence would prefer doing this via a script in one of the extensions.

Can someone please help me with the code. I have the below code which seems to be not working:

Sub %Method%(obj)

' (here) obj = conceptual data model

dim data_item, dummy_domain, assign_domain, e

assign_domain = "Dummy"

' loop over all data items in the model

for each data_item in obj.dataitems

for each dummy_domain in obj.domains

if data_item.dataType = "" and dummy_domain.name = "" then

dummy_domain.SetNameAndCode assign_domain, assign_domain

end if

next

next

output "Done!!!"

End Sub

Accepted Solutions (1)

Accepted Solutions (1)

GeorgeMcGeachie
Active Contributor
0 Kudos

    Hello Amit

    You don't need a script, as you can change all affected Data Items with a single action in a list of Domains, or in a List Report. I would use a List Report, as that saves the filtering for you. Here's what you do:

    • Create a List report, selecting 'Domain' as your object type
    • In the 'Column Filter' select Name, Domain and Data Type
    • Input the Row Filter
    • The Content tab will now show only those Data Items where Data Type = <undefined>
    • Click on the top left corner of the grid to select all of the domains
    • In one of the rows, select the required domain:

    • Every selected Data Item is assigned to the selected domain

    Former Member
    0 Kudos

    Hi George,

    Thanks a lot for the solution, this worked for me.

    --Thanks

    Amit

    Answers (2)

    Answers (2)

    Former Member
    0 Kudos

    Hi George,

    Thanks a lot for your quick replies on my issue. It worked for me both ways.

    Thanks again 🙂

    --Thanks

    Amit

    GeorgeMcGeachie
    Active Contributor
    0 Kudos

    Perhaps I should come in to SAP and provide some training? 🙂

    GeorgeMcGeachie
    Active Contributor
    0 Kudos

    Try this script:

    dim DIT, DOM, DOMName, domTest
    DOMName = "@Dummy"
    set DOM = ActiveModel.FindChildByName(DOMName, Cls_Domain)
    output DOM
    for each DIT in ActiveModel.DataItems  
       'output DIT & " - " & DIT.DataType
       if DIT.DataType = "" then
    	output DIT & " is undefined"
    	set domTest = DIT.Domain  
    	if domTest is Nothing then
    		output "  - has no domain - Domain set to " & domName
    		DIT.Domain = DOM
    	ElseIf Not domTest.Name = DOMName then
    		output "  - has the wrong domain [" & domTest.Name & "] - Domain changed to " & domName
    		DIT.Domain = DOM
    	End If
       end if
    next 
    output "Done!!!"
    GeorgeMcGeachie
    Active Contributor
    0 Kudos

    You could use a variation of this script to create a Custom Check and Autofix script, so these issues are sorted when running a Model Check