ICompoundDimensionInstance.DecomposeElement

Syntax

DecomposeElement(Element; Integer; Var Source: Integer; Var Elements: Array);

Parameters

Element - index of composite dictionary element.

Source - variable, to which composite dictionary source index is placed, to which the elements belongs.

Elements - variable used for positioning index array of source elements. Array dimension is determined by the number of fixed source dimensions Source.

Description

The DecomposeElement method decomposes composite dictionary element into sources.

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;
        Elements: IDimElements;
        Source, i: Integer;
        Arr: Array 
Of Integer;
    
Begin
        MB := MetabaseClass.Active;
        Cube := MB.ItemById(
"Virt_Cube").Bind As IVirtualCube;
        Sources := Cube.Sources;
        
//Generate selection to open composite dictionary
        CDim := Cube.FactDimension As ICompoundDimension;
        CSel := (
New DimSelectionSetFactory.Create).CreateDimSelectionSet;
        
For Each CSource In CDim.Sources Do
        Sel := (
New DimSelectionSetFactory.Create).CreateDimSelectionSet;
        
//Generate selection according to selection of fixed dimensions in data 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;
        
//Open composite dictionary
        Params := (CDim As IMetabaseObject).Params.CreateEmptyValues;
        Params.FindById(
"SELECTIONS").Value := CSel;
        CDimInst := (CDim 
As IMetabaseObject).Open(Params) As ICompoundDimensionInstance;
        
//Index of data used for composing element name
        CDimInst.DecomposeElement(8, Source, Arr);
        CSource := CDim.Sources.Item(Source);
        Debug.WriteLine(
"Source: " + CSource.Name + "(" + CSource.Id + ")");
        Debug.WriteLine(
"Elements of source fixed dimensions");
        FixInfo := Sources.FindByKey(CSource.Key).FixInfo;
        Debug.Indent;
        
For i := 0 To CSource.Dimensions.Count - 1 Do
            Elements := FixInfo.ItemByDim(CSource.Dimensions.Item(i)).Instance.Elements;
            Debug.WriteLine(Elements.Name(Arr[i]));
        
End For;
        Debug.Unindent;
End Sub Main;

After executing the example the console window shows the name of composite dictionary source, the first element belongs to.

See also:

ICompoundDimensionInstance