IMsFormulaInfo.ValidationElement

Syntax

ValidationElement: Integer;

Description

The ValidationElement property returns the element index in validations dimension that corresponds to formula.

Comments

If a point is calculated by a formula from control block, value in this point can be obtained from validations matrix. To get value, create a coordinate that corresponds with the source point and also has the additional validations dimension. The ValidationElement property returns the element index in validations dimension. Validations dimension elements are created on executing control block.

Example

Executing the example requires that the repository contains a calculation algorithm with the CALG_ALG identifier. The algorithm uses control block.

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

Sub UserProc;
Var
    Mb: IMetabase;
    MDesc, MDescChild: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    Calc: IMsProblemCalculation;
    CalcSet: IMsProblemCalculationSettings;
    Variable: IVariableStub;
    SelFactory: DimSelectionSetFactory;
    SelSet, ValSelSet: IDimSelectionSet;
    Sel: IDimSelection;
    Res: IMsFormulaInfoList;
    ResI: IMsFormulaInfo;
    Point: IMsFormulaGenTermPoint;
    DimInst: IDimInstance;
    ValidMatrix: IMatrix;
    NewCoord: IMatrixCoord;
    s: string;
    k, i, El: integer;
Begin
    Mb := MetabaseClass.Active;
    
// Calculation algorithm
    MDesc := Mb.ItemById("CALC_ALG");
    
// Get modeling container
    For Each MDescChild In MDesc.Children Do
        
If MDescChild.ClassId = MetabaseObjectClass.KE_CLASS_MODELSPACE Then
            MDesc := MDescChild;
            
Break;
        
End If;
    
End For;
    
// Get problem
    For Each MDescChild In MDesc.Children Do
        
If MDescChild.ClassId = MetabaseObjectClass.KE_CLASS_MSPROBLEM Then
            
Break;
        
End If;
    
End For;
    Debug.WriteLine(MDescChild.Key.ToString + 
" " + MDescChild.Id + " " + MDescChild.Name);
    
// Calculate problem
    Problem := MDescChild.Edit As IMsProblem;
    CalcSet := Problem.CreateCalculationSettings;
    CalcSet.SupportPartialCalculation := 
True;
    Calc := Problem.Calculate(CalcSet);
    Calc.Run;
    
// Get data source, for which calculation is executed
    Variable := Calc.VariableStubs.Item(0);
    
// Create selection. First dimension elements are selected
    SelFactory := New DimSelectionSetFactory.Create;
    SelSet := SelFactory.CreateDimSelectionSet;
    Sel := SelSet.Add((Variable.Calendar 
As IMetabaseObject).Open(NullAs IDimInstance);
    Sel.SelectElement(
0False);
    k := Variable.DimensionCount;
    
For i := 0 To k - 1 Do
        Sel := SelSet.Add((Variable.Dimension(i) 
As IMetabaseObject).Open(NullAs IDimInstance);
        Sel.SelectElement(
0False);
    
End For;
    
// Get formula information
    Res := Calc.GetFormulaInfo(Variable.Key, SelSet);
    
If (Res.Count = 0Then
        Debug.WriteLine(
"Point is not calculated");
    
Else
        Debug.WriteLine(
"Total number of models, by which point is calculated: " + Res.Count.ToString);
        
For i := 0 To Res.Count - 1 Do
            ResI := Res.Item(i);
            Debug.WriteLine(
"=========== " + (i + 1).ToString + " ===========");
            Debug.WriteLine(
"Model: " + ResI.Model.Name);
            Debug.WriteLine(
"Metamodel: " + ResI.MetaModel.Name);
            Debug.WriteLine(
"Problem: " + ResI.Problem.Name);
            Debug.WriteLine(
"Formula expression: " + ResI.Expression);
            
// Information about calculation point
            Point := ResI.InstancesIterator.LeftPart.Point;
            SelSet := (Point.Coord(
0).MatrixModel As IMatrix).Dimensions;
            
For k := 0 To SelSet.Count - 1 Do
                DimInst := SelSet.Item(k).Dimension;
                s := s + DimInst.Name + 
" = " + DimInst.Elements.Name(Point.Coord(0).Item(k)) + " ";
            
End For;
            Debug.WriteLine(
"Calculation point: " + s);
            
// Get element in validations dimension
</font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;El&nbsp;:=&nbsp;ResI.ValidationElement;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.WriteLine(</font><font color="#800000">&quot;ValidationElement&nbsp;:&nbsp;&quot;</font><font color="#000000">&nbsp;+&nbsp;El.ToString);<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">If</font><font color="#000000">&nbsp;El&nbsp;&lt;&gt;&nbsp;-</font><font color="#008000">1</font><font color="#000000">&nbsp;</font><font color="#008080">Then</font><font color="#000000"><br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;If&nbsp;there is&nbsp;element,&nbsp;get&nbsp;validations&nbsp;matrix<br/> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ValidMatrix&nbsp;:=&nbsp;Calc.GetValidationExceptions(Variable.Key).Execute(</font><font color="#008080">Null</font><font color="#000000">);<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;Create&nbsp;a coordinate&nbsp;to&nbsp;get&nbsp;value&nbsp;from&nbsp;validations&nbsp;matrix<br/> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ValSelSet&nbsp;:=&nbsp;ValidMatrix.Dimensions;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCoord&nbsp;:=&nbsp;ValidMatrix.CreateCoord;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">For</font><font color="#000000">&nbsp;k&nbsp;:=&nbsp;</font><font color="#008000">0</font><font color="#000000">&nbsp;</font><font color="#008080">To</font><font color="#000000">&nbsp;ValSelSet.Count&nbsp;-&nbsp;</font><font color="#008000">1</font><font color="#000000">&nbsp;</font><font color="#008080">Do</font><font color="#000000"><br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sel&nbsp;:=&nbsp;SelSet.FindByKey(ValSelSet.Item(k).Dimension.Key);<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">If</font><font color="#000000">&nbsp;Sel&nbsp;&lt;&gt;&nbsp;</font><font color="#008080">Null</font><font color="#000000">&nbsp;</font><font color="#008080">Then</font><font color="#000000"><br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;If&nbsp;dimension&nbsp;is&nbsp;regular,&nbsp;put&nbsp;element&nbsp;from&nbsp;selection&nbsp;to&nbsp;coordinate<br/> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCoord.Item(k)&nbsp;:=&nbsp;Sel.FirstDimElement;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Else</font><font color="#000000"><br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;If&nbsp;dimension&nbsp;is&nbsp;validations dimension,&nbsp;put&nbsp;the obtained&nbsp;element&nbsp;to&nbsp;coordinate<br/> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCoord.Item(k)&nbsp;:=&nbsp;El;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">If</font><font color="#000000">;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">For</font><font color="#000000">;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;Get&nbsp;value&nbsp;from&nbsp;validations&nbsp;matrix<br/> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.WriteLine(</font><font color="#800000">&quot;Value:&nbsp;&quot;</font><font color="#000000">&nbsp;+&nbsp;ValidMatrix.Item(NewCoord));<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Else</font><font color="#000000"><br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.WriteLine(</font><font color="#800000">&quot;Value:&nbsp;&quot;</font><font color="#000000">&nbsp;+&nbsp;Point.Value(</font><font color="#008000">0</font><font color="#000000">));<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">If</font><font color="#000000">;<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">For</font><font color="#000000">;<br/> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">If</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;UserProc;</font>

After executing the example, the modeling problem used by control block is calculated. The development environment console displays information about the formulas used on calculation in the first model calculation point. The point value is obtained from validations matrix.

See also:

IMsFormulaInfo