CopyToEx (Options: SelectionCopyToExOptions; Dest: IDimSelection; Replace: Boolean);
Options. Determines copied option (selection only, selection and element groups; selection and selection schemas).
Dest. The consumer dimension, to which it is required to copy selection, selection schemas, or element groups from source dimension.
Replace. The parameter that determines whether selection, selection schemas, or element groups contained in the Dest consumer are reset when data is copied.
The CopyToEx method copies the option selected by the Options parameter from source dimension to consumer dimension.
The selection, selection schemas, or groups of elements contained in the Dest consumer are reset when data is copied if the Replace parameters is set to True.
Executing the example requires that the repository contains a table MDM dictionary with the D_COPY_TO_EX identifier containing an element group.
Add links to the Dimensions, Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
dimension: IDimInstance;
sel1, sel2: IDimSelection;
group: IDimElementGroup;
Gp: IMetabaseObjectDescriptors;
i: integer;
Child: IMetabaseObjectDescriptor;
Begin
// Get current repository
Mb := MetabaseClass.Active;
// Get dictionary
dimension := Mb.ItemById("D_COPY_TO_EX").Open(Null) As IDimInstance;
// Get child objects of dictionary
Gp := (dimension As IMetabaseObjectInstance).Object.Children;
// Go through all child objects of dictionary to find element group
For i := 0 To Gp.Count - 1 Do
Child := Gp.Item(i);
// Find element group
If Child.ClassId = MetabaseObjectClass.KE_CLASS_DIMELEMENTGROUP Then
group := Child.Bind As IDimElementGroup;
// Create selections sel1 and sel2
sel1 := dimension.CreateSelection;
sel2 := dimension.CreateSelection;
// Select dictionary element group in selection
sel1.Group := group;
// Copy selection sel1 into selection sel2 together with group
sel1.CopyToEx(SelectionCopyToExOptions.WithGroup, sel2, False);
End If;
End For;
End Sub UserProc;
After executing the example, source dimension group of element and selection are added to the sel2 selection.
See also: