IAlgorithmSettings.PeriodControlEnd

Syntax

PeriodControlEnd: IAlgorithmPeriodControl;

Description

The PeriodControlEnd property returns calculation end 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 and have calculation end date set up. The second parameter is linked to calendar dictionary that contains an attribute with the END_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;
    DataEnd: 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;
    DataEnd := Settings.PeriodControlEnd;
    Debug.WriteLine(DataEnd.IsEnabled);
    // Check if configured calculation end date is used
    If DataEnd.IsEnabled Then
        // Reset specified parameters and set new ones
        DataEnd.Reset;
        // Set the second parameter of calculation algorithm as a calculation end date
        Ms := CalcAlgo.MsProblem;
        MetaModel := Ms.MetaModel;
        Params := MetaModel.Params;
        DataEnd.Parameter := Params.Item(1);
        // Get collection of calculation algorithm parameters
        ParamValues := CalcAlgo.ParamValues;
        ValueList := ParamValues.Values;
        // Get dictionary of the second parameter
        Dim := ValueList.Item(
1).LinkedObject;
        DimInst := Dim.Open(NullAs IDimInstance;
        // Find attribute with the END_DATE identifier
        DimAttr := DimInst.Attributes.FindById("END_DATE");
        // Set obtained dictionary attribute
        DataEnd.Attribute := DimAttr.Attribute;
        // Set calendar level
        DataEnd.OffsetLevel := DimCalendarLevel.Day;
        // Enable displaying of calculation end date on parameters panel
        DataEnd.Visible := True;
        // Save changes in calculation algorithm
        CalcAlgo.SaveObject;
    End If;
End Sub UserProc;

After executing the example, the specified parameters of algorithm calculation end date are reset, and news ones are added:

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

See also:

IAlgorithmSettings