The user can work with hierarchy of MDM dictionary elements using methods of the IRdsDictionaryElements interface.
Executing the example requires the MDM repository NSI_1 that contains the MDM dictionary with the Dict_1 identifier.
Sub Main;
Var
MB: IMetabase;
Dict: IRdsDictionary;
Attrs: IRdsAttributes;
DictInst: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Data: IRdsDictionaryElementData;
i, j: Integer;
Begin
MB := MetabaseClass.Active;
Dict := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_1").Key).Bind As IRdsDictionary;
Attrs := Dict.Attributes;
DictInst := Dict.Open(Null);
Elements := DictInst.Elements;
Data := Elements.CreateData;
Data.Value(Data.AttributeIndex(Attrs .Name.Key)) := The first root one;
i := Elements.Insert(-2, Data);
Data.Value(Data.AttributeIndex(Attrs .Name.Key)) := Second root one;
j := Elements.Insert(-2, Data);
Data.Value(Data.AttributeIndex(Attrs .Name.Key)) := The first child one;
Elements.Insert(i, Data);
Data.Value(Data.AttributeIndex(Attrs .Name.Key)) := Second child one;
Elements.Insert(j, Data);
End Sub Main;
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: