Add(Key: Integer): ICompoundDimensionSource;
Key - key that is assigned to the added source.
The Add method adds source to the collection.
Executing the example requires that repository contains a virtual cube with the CUBE_VIRTUAL identifier and dictionaries with the OBJ_PD_01 and OBJ_PD_02 identifiers.
Sub Main;
Var
Mb: IMetabase;
Obj: IMetabaseObject;
Cub: IVirtualCube;
Dimension: ICompoundDimension;
Source: ICompoundDimensionSource;
dimModel: IDimensionModel;
dimModel1: IDimensionModel;
df: IDimSelectionSetFactory;
Selections: IDimSelectionSet;
dimModelInstance: IDimInstance;
CompoundSelection: IDimSelectionSet;
Cinstance: ICompoundDimensionInstance;
Instance: IDimInstance;
el: IDimElements;
i, j: Integer;
Sel: ICompoundSelection;
Begin
Mb := MetabaseClass.Active;
Obj := Mb.ItemById("CUBE_VIRTUAL").Edit;
Cub := Obj As IVirtualCube;
Dimension := Cub.FactDimension As ICompoundDimension;
If Dimension.CustomContainer <> Null Then
Dimension.CustomContainer := Null;
End If;
Dimension.Sources.Clear;
Source := Dimension.Sources.Add(1);
dimModel := Mb.ItemById("OBJ_PD_01").Bind As IDimensionModel;
dimModel1 := Mb.ItemById("OBJ_PD_02").Bind As IDimensionModel;
Source.Dimensions.Add(dimModel);
Source.Dimensions.Add(dimModel1);
df := New DimSelectionSetFactory.Create;
Selections := df.CreateDimSelectionSet;
dimModelInstance := (dimModel As IMetabaseObject).Open(Null) As IDimInstance;
Selections.Add(dimModelInstance);
dimModelInstance := (dimModel1 As IMetabaseObject).Open(Null) As IDimInstance;
Selections.Add(dimModelInstance);
Selections.Item(0).SelectAll;
Selections.Item(1).SelectAll;
CompoundSelection := df.CreateDimSelectionSet;
Sel := CompoundSelection.AddCompound(1, Selections);
Cinstance := (Dimension As IMetabaseObject).OpenWithParam(CompoundSelection) As ICompoundDimensionInstance;
Instance := Cinstance As IDimInstance;
Debug.WriteLine("Element names");
el := Instance.Elements;
j := Instance.Attributes.FindById("NAME").Attribute.Key;
For i := 0 To el.Count - 1 Do
Debug.WriteLine("Element " + (i + 1).ToString + ": " + (el.AttributeValue(i, j) As String));
End For;
Obj.Save;
End Sub Main;
After executing the example the fact dimension of virtual cube is defined as a composite dictionary. The OBJ_PD_01 and OBJ_PD_02 dictionaries will be included in this dimension. All elements of the composite dictionary will be selected. The console window shows names of all elements of the virtual cube.
See also: