IMsUserTransform.Template

Syntax

Template: IMsUserMethodTemplate

Description

The Template property describes modeling container template used in calculation.

Example

Executing the example requires the KONT_MODEL modeling container. The user method template that contains two parameters is created in the container. The container also includes the User_Var and User_Var_Factor modeling variables that are further used as output and factor ones respectively.

Sub Main;

Var

MB: IMetabase;

MDesc: IMetabaseObjectDescriptor;

CrInf: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Model: IMsModel;

Trans: IMsFormulaTransform;

Varr: IVariableStub;

VarTrans: IMsFormulaTransformVariable;

Tree: IMsFormulaTransformSlicesTree;

Slice: IMsFormulaTransformSlice;

Selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

UserTr: IMsUserTransform;

TransVar: IMsFormulaTransformVariable;

Params: IMsUserMethodParams;

Begin

MB := MetabaseClass.Active;

MDesc := Mb.ItemById("KONT_MODEL");

CrInf := Mb.CreateCreateInfo;

CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;

CrInf.Id := "User_Model";

CrInf.Name := "User_Model";

CrInf.Parent := MDesc;

MObj := Mb.CreateObject(CrInf).Edit;

Model := MObj As IMsModel;

Trans := Model.Transform;

//Output variable

Varr := MB.ItemByIdNamespace("User_Var", MDesc.Key).Bind As IVariableStub;

Trans.Outputs.Add(Varr);

VarTrans := Trans.Outputs.Item(0);

Tree := VarTrans.SlicesTree(VarTrans);

Slice := Tree.CreateSlice(1);

Selector := Trans.CreateSelector;

Selector.Slice := Slice;

Formula := Trans.Transform(Selector);

Formula.Kind := MsFormulaKind.User;

Formula.Level := DimCalendarLevel.Year;

UserTr := Formula.Method As IMsUserTransform;

UserTr.Template := (MDesc.Bind As IMsModelSpace).UserMethodTemplates.Item(0);

//Factor

Varr := MB.ItemByIdNamespace("User_Var_Factor", MDesc.Key).Bind As IVariableStub;

Trans.Inputs.Add(Varr);

TransVar := Model.Transform.Inputs.Item(0);

UserTr.Explanatories.Add(TransVar.SlicesTree(Null).CreateSlice(1));

Params := UserTr.Params;

Params.Item(0).Value := 10;

Params.Item(1).Value := 100;

MObj.Save;

End Sub Main;

After executing the example a model is created in the modeling container. For model calculation the user method implemented in the module, to which the first modeling container template refers, is used. The output variable and a factor are added to the model, and the parameter values are set.

See also:

IMsUserTransform