Matrix(Index: Integer): IMatrix;
Index. Index of the source, which data matrix should be obtained.
The Matrix property returns the matrix of the virtual cube data source.
Executing the example requires that the repository contains a virtual cube with the VIRT_CUBE identifier. The virtual cube contains at least one data source with two dimensions. The dimensions are not fixed in the virtual cube.
Add links to the Cubes, Dimensions, Matrix, and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Desc: IMetabaseObjectDescriptor;
Cube: ICubeInstance;
Dest: ICubeInstanceDestination;
Sels: IDimSelectionSet;
Sel: IDimSelection;
Exec: ICubeInstanceDestinationExecutor;
Matrs: IVirtualCubeSourceMatrices;
Matr: IMatrix;
Coord: IMatrixCoord;
Begin
// Open cube
MB := MetabaseClass.Active;
Desc := MB.ItemById("VIRT_CUBE");
Cube := Desc.Open(Null) As ICubeInstance;
Dest := Cube.Destinations.DefaultDestination;
// Set selection
Sels := Dest.CreateDimSelectionSet;
For Each Sel In Sels Do
Sel.SelectAll;
End For;
// Calculate virtual cube with access to source matrices
Exec := Dest.CreateExecutorO(CubeInstanceDestinationExecutorOptions.KeepSourceMatrices);
Exec.PrepareExecute(Sels);
Exec.PerformExecute;
// Access source matrices
Matrs := Exec.Matrix As IVirtualCubeSourceMatrices;
Debug.WriteLine("Number of source matrices: " + Matrs.Count.ToString);
// Replace data of one of the sources, after which data of the output matrix also changes
Matr := Matrs.Matrix(0);
Coord := Matr.CreateCoord;
Coord.Item(0) := 0;
Coord.Item(1) := 0;
Matr.Item(Coord) := 100;
// Replace data of the output matrix, after which data of the corresponding source changes
Matr := Exec.Matrix;
Coord := Matr.CreateCoord;
Coord.Item(0) := 0;
Coord.Item(1) := 0;
Coord.Item(2) := 0;
Matr.Item(Coord) := 200;
End Sub UserProc;
After executing the example the output matrix of the virtual cube is calculated in the source matrix access mode. The number of available matrices is displayed in the development environment console. The code generally displays the example of data change in the source matrix of the virtual cube without saving of changed data.
See also: