Frequencies: DimCalendarLevelSet;
The Frequencies property determines calendar frequency of iterations.
It is forbidden to use the Frequencies and IMsCalculationChainIterator.UseDates properties at the same time.
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 Dimensions, Metabase, Ms 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";
// 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 cycle will perform iteration by frequency
Iterator.Frequencies := DimCalendarLevelSet.Year Or DimCalendarLevelSet.Quarter;
// Set step of dates for iterations using parameter
Iterator.StepParam := "STEP";
// Save changes
(MetaModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, calculation frequency will be set for the cycle.
See also: