ICompoundDimensionInstance.ComposeElement

Syntax

ComposeElement(Source: Integer; Elements: Array): Integer;

Parameters

Source - index of composite dictionary source, to which the element belongs.

Elements - array of the indexes of source-elements. Array dimension is determined by the number of fixed source dimensions Source.

Description

The ComposeElement method returns index of composite dictionary element by its sources.

If the element is not found, this method returns value -1.

Example

Executing the example requires that the repository contains a virtual cube with the Virt_Cube identifier.

Sub Main;

Var

MB: IMetabase;

Cube: IVirtualCube;

Sources: IVirtualCubeSources;

CDim: ICompoundDimension;

CSource: ICompoundDimensionSource;

CSel, Sel: IDimSelectionSet;

FixInfo: ICubeDimensionFixInfo;

Fix: ICubeDimensionFix;

Params: IMetabaseObjectParamValues;

CDimInst: ICompoundDimensionInstance;

Instance: IDimInstance;

Elements: IDimElements;

Source, i: Integer;

Arr: Array Of Integer;

Begin

MB := MetabaseClass.Active;

Cube := MB.ItemById("Virt_Cube").Bind As IVirtualCube;

Sources := Cube.Sources;

//Forming selection to open composite dictionary

CDim := Cube.FactDimension As ICompoundDimension;

Sel := (New DimSelectionSetFactory.Create).CreateDimSelectionSet;

CSel := (New DimSelectionSetFactory.Create).CreateDimSelectionSet;

For Each CSource In CDim.Sources Do

Sel.Clear;

//Forming selection in accordance with selection of fixed dimension in the sources

FixInfo := Sources.FindByKey(CSource.Key).FixInfo;

For Each Fix In FixInfo Do

If Fix.Selection.SelectedCount <> 0 Then

Fix.Selection.CopyTo(Sel.Add(Fix.Instance), True);

End If;

End For;

CSel.AddCompound(CSource.Key, Sel);

End For;

//Opening composite dictionary

Params := (CDim As IMetabaseObject).Params.CreateEmptyValues;

Params.FindById("SELECTIONS").Value := CSel;

CDimInst := (CDim As IMetabaseObject).Open(Params) As ICompoundDimensionInstance;

//Get elements of composite dictionary

Instance := CDimInst As IDimInstance;

Elements := Instance.Elements;

//Index of the last data source

Source := CDim.Sources.Count - 1;

//The last data source

CSource := CDim.Sources.Item(Source);

//The array of elements indexes for receiving index of composite dictionary element

Arr := New Integer[CSource.Dimensions.Count];

For i := 0 To CSource.Dimensions.Count - 1 Do

Arr[i] := 0;

End For;

//Element index in composite dictionary

i := CDimInst.ComposeElement(Source, Arr);

If i <> -1 Then

Debug.WriteLine(Elements.Name(i));

End If;

End Sub Main;

After executing the example the composite dictionary of a virtual cube is obtained. The development environment console displays the name of data source and elements of fixed source dimensions, that are used to create the name of the specified element of composite dictionary.

See also:

ICompoundDimensionInstance