IMsDatePeriod.AutoPeriodDates

Syntax

AutoPeriodDates(Calculation: IMsMethodCalculation;

                Coord: IMsFormulaTransformCoord;

                Var AutoStartDate: DateTime;

                Var AutoEndDate: DateTime);

Parameters

Calculation. Settings that are necessary on model calculation.

Coord. Parameters of the variable coordinate, by which calculation will be executed.

AutoStartDate. Period start date.

AutoEndDate. Period end date.

Description

The AutoPeriodDates method returns period limits if conditions to calculate period start and end dates are used.

Comments

The AutoStartDate and AutoEndDate parameters must be variables. After executing the method they will contain results.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a model with the MODEL_FREEDIM identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    DescrCM: IMetabaseObjectDescriptor;
    pModel: IMsModel;
    trans: IMsFormulaTransform;
    coo: IMsFormulaTransformCoord;
    calc: IMsMethodCalculation;
    Period: IMsModelPeriod;
    OutputPeriod: IMsDatePeriod;
    StDate, EndDate: DateTime;
Begin
    // Get model
    mb := MetabaseClass.Active;
    DescrCM := mb.ItemById("MS");
    pModel := mb.ItemByIdNamespace("MODEL_FREEDIM", DescrCM.Key).Edit As IMsModel;
    // Set calculation options
    trans := pModel.Transform;
    coo := trans.CreateCoord(trans.Outputs.Item(0));
    calc := trans.CreateCalculation;
    // Set calculation periods
    Period := pModel.Transform.Period;
    calc.Period.IdentificationStartDate := Period.IdentificationStartDate;
    calc.Period.IdentificationEndDate := Period.IdentificationEndDate;
    calc.Period.ForecastStartDate := Period.ForecastStartDate;
    calc.Period.ForecastEndDate := Period.ForecastEndDate;
    calc.CurrentPoint := Period.IdentificationStartDate;
    OutputPeriod := trans.OutputPeriod As IMsDatePeriod;
    // Clear parameters of data loading period
    OutputPeriod.ClearPeriod;
    // Set autoperiod parameters: data loading period is determined by current date
    OutputPeriod.AutoPeriod := MsDateAutoPeriodOptions.StartAsNow Or MsDateAutoPeriodOptions.EndAsNow;
    // Set moving of start and end dates for data loading period
    OutputPeriod.StartOffset := 1;
    OutputPeriod.EndOffset := 2;
    // Get and display in the console period start and end dates of data loading
    OutputPeriod.AutoPeriodDates(calc, coo, StDate, EndDate);
    Debug.WriteLine("Data uploading start: " + StDate.ToString);
    Debug.WriteLine("Data loading end: " + EndDate.ToString);
    // Save changes
    (pModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example data calculation and loading periods will be set for the model. Data loading period will be set using conditions, period actual dates will be displayed in the console.

See also:

IMsDatePeriod