LevelParam: String;
LevelParam: string;
The LevelParam property determines parameter which sets method calculation dynamics.
To set directly calculation frequency, use the IMsFormula.Level property.
Executing the example requires that the repository contains a modeling container with the MS identifier. This container must contain metamodel with the META_LEVELPARAM identifier calculating model with the MODEL_LEVELPARAM identifier.
Add links to the Dimensions, Metabase, Ms, Transform system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Metamodel: IMsMetaModel;
Params: IMsModelParams;
Param: IMsModelParam;
Model: IMsModel;
Formula: IMsFormula;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
Metamodel := mb.ItemByIdNamespace("META_LEVELPARAM", MsKey).Edit As IMsMetaModel;
// Get metamodel parameters collection
Params := Metamodel.Params;
// Clear metamodel parameters collection
Params.Clear;
// Add a new parameter
Param := Params.Add;
// Determine parameter type - frequency
Param.ParamType := TsParamType.Frequency;
// Set default value - annual frequency
Param.DefaultValue := DimCalendarLevelSet.Year;
// Set parameter name and identifier
Param.Name := "Calculation frequency";
Param.Id := "Formula_Level";
// Save changes of the metamodel
(Metamodel As IMetabaseObject).Save;
// Get the model
Model := mb.ItemByIdNamespace("MODEL_LEVELPARAM", MsKey).Edit As IMsModel;
// Get model calculation method
Formula := Model.Transform.FormulaItem(0);
// Determine that model calculation frequency will be determined by the following parameter
Formula.LevelParam := "Formula_Level";
// Save changes in the model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the MODEL_LEVELPARAM model will be calculated using by frequency set by the Formula_Level parameter.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Transform;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
Metamodel: IMsMetaModel;
mParams: IMsModelParams;
Param: IMsModelParam;
Model: IMsModel;
Formula: IMsFormula;
Begin
// Get current repository
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
Metamodel := mb.ItemByIdNamespace["META_LEVELPARAM", MsKey].Edit() As IMsMetaModel;
// Get metamodel parameters collection
mParams := Metamodel.Params;
// Clear metamodel parameters collection
mParams.Clear();
// Add a new parameter
Param := mParams.Add();
// Determine parameter type - frequency
Param.ParamType := TsParamType.tsptFrequency;
// Set default value - annual frequency
Param.DefaultValue := DimCalendarLevelSet.dclsYear;
// Set parameter name and identifier
Param.Name := "Calculation frequency";
Param.Id := "Formula_Level";
// Save changes of the metamodel
(Metamodel As IMetabaseObject).Save();
// Get the model
Model := mb.ItemByIdNamespace["MODEL_LEVELPARAM", MsKey].Edit() As IMsModel;
// Get model calculation method
Formula := Model.Transform.FormulaItem[0];
// Determine that model calculation frequency will be determined by the following parameter
Formula.LevelParam := "Formula_Level";
// Save changes in the model
(Model As IMetabaseObject).Save();
End Sub;
See also: