StepParam: String;
The StepParam property determines a parameter that sets cycle calculation step.
Calculation step is set using calculation by dates, that is, the IMsCalculationChainIterator.UseDates property should be set to True.
To set calculation step directly, use the IMsCalculationChainIterator.Step_ property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a metamodel with the METAMODEL_ITERATOR identifier and a model with the MODEL_ITERATOR identifier.
Add links to the Dal, Dimensions, Metabase, Ms, and Transform system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
MetaModel: IMsMetaModel;
Param: IMsModelParam;
CalcChain: IMsCalculationChainEntries;
Iterator: IMsCalculationChainIterator;
Model: IMsModel;
Formula: IMsFormula;
Expr: IExpression;
Begin
// Get current
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace("METAMODEL_ITERATOR", MsKey).Edit As IMsMetaModel;
// Clear metamodel parameters collection
MetaModel.Params.Clear;
// Add parameter which will be responsible for cycle calculation
Param := MetaModel.Params.Add;
Param.DefaultValue := 0;
Param.Id := "THRESHOLD";
Param.Name := "Threshold";
// Add parameter which will be responsible for
// the cycle iterations start date
Param := MetaModel.Params.Add;
Param.DataType := DbDataType.Date;
Param.ParamType := TsParamType.Date;
Param.DefaultValue := DateTime.Parse("01.01.2000");
Param.Id := "ST_DATE";
Param.Name := "Iterations start date";
// Add parameter which will be responsible for
// cycle iterations end date
Param := MetaModel.Params.Add;
Param.DataType := DbDataType.Date;
Param.ParamType := TsParamType.Date;
Param.DefaultValue := DateTime.Parse("01.01.2017");
Param.Id := "END_DATE";
Param.Name := "Iterations end date";
// Add parameter which will be responsible for
// cycle iterations step
Param := MetaModel.Params.Add;
Param.ParamType := TsParamType.Frequency;
Param.DefaultValue := DimCalendarLevel.Week;
Param.Id := "STEP";
Param.Name := "Iterations step";
// Get and clear metamodel calculation chain
CalcChain := MetaModel.CalculationChain;
CalcChain.Clear;
// Create cycle in metamodel calculation chain
Iterator := CalcChain.AddIterator("Cycle");
// Set cycle execution conditions
Iterator.PostCondition := True;
Iterator.MaxIterations := 600;
Expr := Iterator.Expression;
Expr.AsString := "{THRESHOLD}<5";
// Get the model
Model := mb.ItemByIdNamespace("MODEL_ITERATOR", MsKey).Edit As IMsModel;
// Clear model calculation dynamics
Formula := Model.Transform.FormulaItem(0);
Formula.Level := DimCalendarLevel.Root;
// Save changes in the model
(Model As IMetabaseObject).Save;
// Add this model to the cycle
Iterator.Contents.AddModel(model);
// Determine that the cycle will execute iteration by dates
Iterator.UseDates := True;
// Set iteration dates using parameters
Iterator.StartParamID := "ST_DATE";
Iterator.EndParamID := "END_DATE";
// Set step of dates for iterations using parameter
Iterator.StepParam := "STEP";
(MetaModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example cycle iteration will be executed by specified dates with determined step. Dates and step will be set using parameters.
See also: