OutputPeriod: IMsPeriod;
The OutputPeriod property returns data loading period parameters.
To set up parameters of model calculation period, use the IMsFormulaTransform.Period property.
Executing the example requires that repository contains modeling container with the MS identifier. The container must contain metamodel with the METAMODEL_TRANSF_OUTPUT identifier including model with the MODEL_TRANSF_OUTPUT identifier to the calculation chain.
Add links to the Dal, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
MetaModel: IMsMetaModel;
pParams: IMsModelParams;
pPar: IMsModelParam;
pModel: IMsModel;
pPeriod: IMsDatePeriod;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace("METAMODEL_TRANSF_OUTPUT", MsKey).Edit As IMsMetaModel;
// Get metamodel parameters
pParams := MetaModel.Params;
// Remove all parameters
pParams.Clear;
// Add metamodel parameter to set start of data downloading period
pPar := pParams.Add;
pPar.Id := "OUT_START";
pPar.Name := "Data downloading start";
pPar.DataType := DbDataType.Date;
pPar.DefaultValue := DateTime.Parse("01.01.2018");
// Add metamodel parameter to set data downloading period end
pPar := pParams.Add;
pPar.Id := "OUT_END";
pPar.Name := "Data downloading end";
pPar.DataType := DbDataType.Date;
pPar.DefaultValue := DateTime.Parse("01.01.2020");
// Save changes of the metamodel
(MetaModel As IMetabaseObject).Save;
// Get the model
pModel := mb.ItemByIdNamespace("MODEL_TRANSF_OUTPUT", MsKey).Edit As IMsModel;
// Get model calculation period parameters
pPeriod := pModel.Transform.OutputPeriod As IMsDatePeriod;
pPeriod.ClearPeriod;
// Set model parameters determining start and end of data downloading period
pPeriod.StartParam.Parameter := pParams.FindById("OUT_START");
pPeriod.EndParam.Parameter := pParams.FindById("OUT_END");
// Save changes in the model
(pModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the start and end of the model data loading period will be set by the OUT_START and OUT_END parameters.
See also: