IMatrixChangesInfo.ItemID

Syntax

ItemID(Index: Integer): Integer;

Parameters

Index. Element index in the changes collection.

Description

The ItemID property returns identifier of the element with changed matrix data.

Comments

The obtained identifier can be used in the properties: IMatrixChangesInfo.OriginalValueByItemID, IMatrixChangesInfo.OriginalValueFlagByItemID, IMatrixChangesInfo.StateByItemID, methods: IMatrixCoord.GotoItemID, IMatrixIterator.GotoItemID.

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, id: 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
        id := Changes.ItemID(0);
        Debug.Write("OriginalValueByItemID: " + Changes.OriginalValueByItemID(id));
        Debug.Write(". OriginalValueFlagByItemID: " + Changes.OriginalValueFlagByItemID(id).ToString);
        Debug.WriteLine(". StateByItemID: " + Changes.StateByItemID(id).ToString);
    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;

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 the change is displayed in the development environment console. The element with information about changes is addressed by its identifier.

See also:

IMatrixChangesInfo