IMsCalculationChainIterator.UseDates

Syntax

UseDates: Boolean;

Description

The UseDates property determines whether a cycle is calculated by dates.

Comments

Available values:

NOTE. It is forbidden to use the UseDates and IMsCalculationChainIterator.Frequencies properties at the same time.

Example

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;
    Calend: IMsCalendarSettings;
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 the cycle will execute iteration by dates
    Iterator.UseDates := True;
    // Determine iteration dates
    Iterator.StartDate := DateTime.Parse("01.01.2000");
    Iterator.EndDate := DateTime.Parse("01.01.2017");
    // Set date step for iterations
    Iterator.Step_ := DimCalendarLevel.Week;
    // Get cycle calendar frequency parameters
    Calend := Iterator.CalendarSettings;
    // Determine that Friday and Saturday are holydays
    Calend.RestDays := DayOfWeekSet.Friday Or DayOfWeekSet.Saturday;
    // Save changes of the metamodel
    (MetaModel As IMetabaseObject).Save;
End Sub;

After executing the example cycle iteration will be executed by specified dates with determined step.

See also:

IMsCalculationChainIterator