The user can work with hierarchy of MDM dictionary elements using methods of the IRdsDictionaryElements interface.
Executing the example requires an MDM dictionary with the RDS_DICT identifier.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Dict: IRdsDictionary;
Attrs: IRdsAttributes;
DictInst: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Data: IRdsDictionaryElementData;
i, j: Integer;
Begin
MB := MetabaseClass.Active;
Dict := MB.ItemById("RDS_DICT").Bind As IRdsDictionary;
Attrs := Dict.Attributes;
DictInst := Dict.Open(Null);
Elements := DictInst.Elements;
Data := Elements.CreateData;
Data.Value(Data.AttributeIndex(Attrs.Name.Key)) := "First root";
i := Elements.Insert(-2, Data);
Data.Value(Data.AttributeIndex(Attrs.Name.Key)) := "Second root";
j := Elements.Insert(-2, Data);
Data.Value(Data.AttributeIndex(Attrs.Name.Key)) := "First child";
Elements.Insert(i, Data);
Data.Value(Data.AttributeIndex(Attrs.Name.Key)) := "Second child";
Elements.Insert(j, Data);
End Sub UserProc;
After executing the example four new elements are created in the MDM dictionary: two root elements and one child element for each root one.
See also: