IAlgorithmSettings.PeriodControlStart

Syntax

PeriodControlStart: IAlgorithmPeriodControl;

Description

The PeriodControlStart property returns calculation start date settings.

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. The calculation algorithm should contains at least two parameters. The first parameter is linked to calendar dictionary that contains an attribute with the START_DATE identifier.

Add links to the Algo, Cubes, Dimensions, Metabase, Ms system assemblies. Add links to the assemblies required for working with calculation algorithms.

Sub UserProc;
Var
    MB: IMetabase;
    MObj, Dim: IMetabaseObjectDescriptor;
    Algo: ICalcObject;
    CalcAlgo: ICalcAlgorithm;
    Settings: IAlgorithmSettings;
    Start: IAlgorithmPeriodControl;
    Ms: IMsProblem;
    MetaModel: IMsMetaModel;
    Params: IMsModelParams;
    ParamValues: IAlgorithmParameterValues;
    DimInst: IDimInstance;
    DimAttr: IDimAttributeInstance;
    ValueList: IAlgorithmParamValueList;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Get algorithm calculation period settings
    Settings := CalcAlgo.Settings;
    // Get calculation start date settings
    Start := Settings.PeriodControlStart;
    // Set the first parameter of calculation algorithm as a calculation start date
    Ms := CalcAlgo.MsProblem;
    MetaModel := Ms.MetaModel;
    Params := MetaModel.Params;
    Start.Parameter := Params.Item(0);
    // Get collection of calculation algorithm parameters
    ParamValues := CalcAlgo.ParamValues;
    ValueList := ParamValues.Values;
    // Get dictionary of the first parameter
    Dim := ValueList.Item(0).LinkedObject;
    DimInst := Dim.Open(NullAs IDimInstance;
    // Find attribute with the START_DATE identifier
    DimAttr := DimInst.Attributes.FindById("START_DATE");
    // Set obtained dictionary attribute
    Start.Attribute := DimAttr.Attribute;
    // Set calendar level
    Start.OffsetLevel := DimCalendarLevel.Day;
    // Set shift of calculation start date
    Start.OffsetValue := 2;
    // Enable displaying of calculation start date on parameters panel
    Start.Visible := True;
    // Check if there are changes in calculation period settings
    If Settings.IsDirty Then
        // Save changes in calculation algorithm
        CalcAlgo.SaveObject;
    End If;
End Sub UserProc;

After executing the example, the algorithm calculation start date parameters are set:

The specified algorithm calculation start date is displayed on the parameters panel.

See also:

IAlgorithmSettings