ICubeInstanceStorage.SaveMatrix

Syntax

SaveMatrix(Matrix: IMatrix; ValueFlag: Integer);

Parameters

Matrix - matrix that contains values that must be saved back to a cube.

ValueFlag - flag of elements that contain changed data. Only the matrix elements, which flags correspond to this value, are saved to a cube.

Description

The SaveMatrix method saves the matrix with data to a cube.

Example

Class CubeCallback: Object, ICubeCallback

Public Sub OnCallback(Argument: ICubeCallbackArgument);

Begin

Debug.WriteLine(Error: + Argument.Error.Message);

Debug.WriteLine(Error identifier: + Argument.Error.MessageID.ToString);

Debug.WriteLine(Source: + Argument.Error.Source);

Argument.IgnoreError := True;

End Sub OnCallback;

Public Function get_Argument: ICubeCallbackArgument;

Begin

Return Null;

End Function get_Argument;

End Class CubeCallback;

Sub Main;

Var

MB: IMetabase;

CubInst: ICubeInstance;

Des: ICubeInstanceDestination;

Sels: IDimSelectionSet;

Mat: IMatrix;

Coord: IMatrixCoord;

Sto: ICubeInstanceStorage;

i: Integer;

Begin

MB := MetabaseClass.Active;

CubInst := MB.ItemById("CUBE_1").Open(Null) As ICubeInstance;

Des := CubInst.Destinations.DefaultDestination;

Sels := Des.CreateDimSelectionSet;

For i := 0 To Sels.Count - 1 Do

Sels.Item(i).SelectElement(0, False);

End For;

Mat := Des.Execute(Sels);

Mat.ValueFlag := Mat.ValueFlag + 1;

Sels := Mat.Dimensions;

Coord := Mat.CreateCoord;

For i := 0 To Sels.Count - 1 Do

Coord.Item(i) := 0;

End For;

Mat.Item(Coord) := (Mat.Item(Coord) As Double) + 1;

Sto := Des.CreateStorage(CubeInstanceStorageOptions.NoCheckDuplicates);

Sto.Callback := New CubeCallback.Create;

Sto.SaveMatrix(Mat, Mat.ValueFlag);

End Sub Main;

After executing the example a matrix with data is obtained from the cube with the CUBE_1 identifier. The value is changed by some coordinate, following which an updated matrix is saved back to the cube. During saving, duplicates availability is not checked. Errors that may occur are handled in the CubeCallback custom class.

See also:

ICubeInstanceStorage