FindFormulas(FindInfo: IMsFindFormulaInfo): IMsFindFormulaResults;
FindInfo. Search parameters.
The FindFormulas method searches for formulas according to the specified parameters.
To set search conditions, use the CreateFormulaFindInfo property.
Executing the example requires that the repository contains a modeling container with the MS identifier. A data source for the modeling container is a cube with the STD_CUBE identifier. The cube structure contains a dimension with the CITY identifier. The modeling container has a modeling problem with the PROBLEM identifier.
Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Problem: IMsProblem;
MetaModel: IMsMetaModel;
VarStub: IVariableStub;
FindInfo: IMsFindFormulaInfo;
Factory: IDimSelectionSetFactory;
DimSS: IDimSelectionSet;
Begin
Mb := MetabaseClass.Active;
Problem := Mb.ItemByIdNamespace("PROBLEM", Mb.GetObjectKeyById("MS")).Bind As IMsProblem;
MetaModel := Problem.MetaModel;
VarStub := Mb.ItemById("STD_CUBE").Bind As IVariableStub;
Factory := New DimSelectionSetFactory.Create;
// Selection of element that will be searched in formula terms
DimSS := Factory.CreateDimSelectionSet;
DimSS.Add(Mb.ItemById("CITY").Open(Null) As IDimInstance).SelectElement(0, False);
// Search conditions
FindInfo := MetaModel.CreateFormulaFindInfo;
FindInfo.Stub := VarStub;
FindInfo.Selection := DimSS;
FindInfo.VarKind := MsVariableKind.Input;
// Search and view results
ShowMsFindResults(MetaModel.FindFormulas(FindInfo));
End Sub UserProc;
Sub ShowMsFindResults(Results: IMsFindFormulaResults);
Var
Result: IMsFindFormulaResult;
Model: IMsFindFormulaResultModel;
Branch: IMsFindFormulaResultBranchCondition;
Expr: IMsBranchConditionExpression;
i, c: Integer;
Begin
c := Results.Count;
Debug.WriteLine("Formulas found: " + c.ToString);
For i := 0 To c - 1 Do
Result := Results.Item(i);
Select Case Result.Type
Case MsCalculationChainEntryType.Model: Debug.WriteLine("-Model-");
Case MsCalculationChainEntryType.Branch: Debug.WriteLine("-Branch-");
End Select;
If Result Is IMsFindFormulaResultModel Then
Model := Result As IMsFindFormulaResultModel;
If Not IsNull(Model.ChainMetamodel) Then
Debug.WriteLine("Model parernt: " + Model.ChainMetamodel.Name);
End If;
Debug.WriteLine("Model: " + Model.ChainEntry.Name);
Elseif Result Is IMsFindFormulaResultBranchCondition Then
Branch := Result As IMsFindFormulaResultBranchCondition;
If Not IsNull(Branch.ChainMetamodel) Then
Debug.WriteLine("Branch parernt: " + Branch.ChainMetamodel.Name);
End If;
Debug.WriteLine("Branch: " + Branch.ChainEntry.Name);
Debug.WriteLine("Case: " + Branch.BranchCase.Name);
If Branch.BranchCondition Is IMsBranchConditionExpression Then
Expr := Branch.BranchCondition As IMsBranchConditionExpression;
Debug.WriteLine("Condition: " + Branch.BranchCondition.Key.ToString + " " + Expr.Expression.AsString);
End If;
End If;
Debug.WriteLine("-------");
End For;
End Sub ShowMsFindResults;
After executing the example, the formulas are searched that contain terms based on the first element of the CITY dimension of modeling container data source. Information about the found formulas will be displayed in the development environment console.
See also: