Level: DimCalendarLevel;
The Level property determines the calendar level that should be used for problem calculation.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. The metamodel with the META_MODEL identifier must be present in this container. The calendar of the container must begin before 2003, and come to an end after 2010.
Sub Main;
Var
MB: IMetabase;
Cont: IMetabaseObjectDescriptor;
ModelKey: Integer;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Problem: IMsProblem;
LnDecProblem: MsLinearDecompositionProblem;
Period: IMsModelPeriod;
Begin
MB := MetabaseClass.Active;
Cont := Mb.ItemById("CONT_MODEL").Bind;
ModelKey := Cont.Key;
// Create the Problem object
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSPROBLEM;
CrInf.Id := "New_ForwardLookingProblem";
CrInf.Name := "New_ForwardLookingProblem";
CrInf.Parent := Cont;
CrInf.Permanent := False;
MObj := Mb.CreateObject(CrInf).Edit;
Problem := MObj As IMsProblem;
// Add the metamodel
Problem.MetaModel := MB.ItemByIdNamespace("META_MODEL", ModelKey).Bind As IMsMetaModel;
// Determine the problem type - Forward-looking forecasting
LnDecProblem := New MsLinearDecompositionProblem.Create;
Problem.Details := LnDecProblem;
// Determine a calendar level on which calculation of a problem is executed
LnDecProblem.Level := DimCalendarLevel.Month;
// Determine parameters of the periods on which calculation of problem is executed
Period := LnDecProblem.Period;
Period.IdentificationStartDate := DateTime.ComposeDay(2003, 1, 1);
Period.IdentificationEndDate := DateTime.ComposeDay(2007, 12, 31);
Period.ForecastStartDate := DateTime.ComposeDay(2008, 1, 1);
Period.ForecastEndDate := DateTime.ComposeDay(2010, 12, 31);
MObj.Save;
End Sub Main;
After executing the example, a new problem of the Forward-Looking Forecasting type with the New_ForwardLookingProblem identifier is created in the modeling container. The metamodel is added to the problem, the level of a calendar and parameters of the periods necessary for calculation of a problem are determined.
See also: