Skip to Content
0

powerdesigner : Assign domains to data items

Jun 12 at 07:23 AM

26

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
George McGeachie Jun 12 at 09:22 AM
0

    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


    Show 1 Share
    10 |10000 characters needed characters left characters exceeded

    Hi George,

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

    --Thanks

    Amit

    0
    George McGeachie Jun 12 at 10:02 AM
    0

    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!!!"
    Show 1 Share
    10 |10000 characters needed characters left characters exceeded

    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

    0
    Amit Kumar Pathak
    Jun 12 at 10:29 AM
    0

    Hi George,

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

    Thanks again :)

    --Thanks

    Amit

    Show 1 Share
    10 |10000 characters needed characters left characters exceeded

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

    0