IMatrixEx.ChangesInfo

Syntax

ChangesInfo: IMatrixChangesInfo;

Description

The ChangesInfo property returns information about matrix changes.

Comments

To register information about changes, set the PreserveOriginalValues property to True.

Example

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

Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    Sel: IDimSelection;
    Exec: ICubeInstanceDestinationExecutor;
    Matr: IMatrix;
    MatrEx: IMatrixEx;
    Coord: IMatrixCoord;
    Changes: IMatrixChangesInfo;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemById("CUBE_1").Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    // Create selection
    Sels := Dest.CreateDimSelectionSet;
    For Each Sel In Sels Do
        Sel.SelectAll;
    End For;
    // Calculation settings
    Exec := Dest.CreateExecutor;
    Exec.PrepareExecute(Sels);
    // Cube calculation
    Exec.PerformExecute;
    Matr := Exec.Matrix;
    // Mode of separate storage of source and changed data
    MatrEx := Matr As IMatrixEx;
    MatrEx.PreserveOriginalValues := True;
    Matr.ValueFlag := Matr.ValueFlag + 1;
    // Create a coordinate and change coordinate value in matrix
    Coord := Matr.CreateCoord;
    For i := 0 To Coord.Count - 1 Do
        Coord.Item(i) := 0;
    End For;
    Matr.Item(Coord) := 300;
    // View changes
    Changes := MatrEx.ChangesInfo;
    If Changes <> Null Then
        ShowChanges(Changes);
    Else
        Return;
    End If;
    // If new value is greater than old one, apply changes, otherwise cancel changes
    If Matr.Item(Coord) > Changes.OriginalValue(0Then
        MatrEx.ApplyChanges(False);
    Else
        MatrEx.RevertChanges(11);
    End If;
    //...
    //Further work with matrix
    //...
End Sub UserProc;

Sub ShowChanges(Changes: IMatrixChangesInfo);
Var
    i, c: Integer;
Begin
    c := Changes.Count;
    For i := 0 To c - 1 Do
        Debug.Write("ItemID: " + Changes.ItemID(i).ToString);
        Debug.Write(". OriginalValue: " + Changes.OriginalValue(i));
        Debug.Write(". OriginalValueFlag: " + Changes.OriginalValueFlag(i).ToString);
        Debug.WriteLine(". State: " + Changes.State(i).ToString);
    End For;
End Sub ShowChanges;

After executing the example an output cube matrix is calculated. Mode of separate storage of source and changed data is enabled for the matrix, after which cell value is changed. Information about changes is displayed in the development environment console.

See also:

IMatrixEx