SelectionControl: ICubeSelectionControl;
The SelectionControl property returns parameters of controlling dimensions for parameterization of multidimensional calculation.
Executing the example requires that the repository contains a database with the DB identifier, standard parametric cubes with the CUBE_DEST and CUBE_SOUR identifiers. The CUBE_DEST cube as a fact must use a dictionary with the PARAM_DICT identifier.
Sub Main;
Var
Mb: IMetabase;
dMd: IMetabaseObjectDescriptor;
MDcalc: IMDCalculation;
FormulasTable: IMDCalculationFormulasTable;
TableForFormulas: ITable;
destination: IMDCalculationDestination;
source: IMDCalculationSource;
Cub: ICubeModel;
sel: ICubeSelectionControl;
param: IMetabaseObjectParam;
dim: IDimensionModel;
Des: IMetabaseObjectDescriptor;
CrInf: IMetabaseObjectCreateInfo;
objContrl: IMetabaseObjectControl;
Params: IMetabaseObjectParams;
DictParam: IMetabaseObjectDescriptor;
Begin
Mb := MetabaseClass.Active;
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MDCALCULATION;
CrInf.Name := "MDCALC";
CrInf.Id := "MDCALC";
CrInf.Parent := Mb.Root;
CrInf.Permanent := True;
Des := Mb.CreateObject(CrInf);
dMd := Des.Edit;
MDcalc := dMd As IMDCalculation;
// Determine DB
MDcalc.Database := Mb.ItemById("DB").Bind As IDatabase;
Destination := MDcalc.Destination;
// Determine destination cube
Cub := Mb.ItemById("CUBE_DEST").Bind As ICubeModel;
Destination.SetCube(Cub);
// Determine source cube
Cub := Mb.ItemById("CUBE_SOUR").Bind As ICubeModel;
source := MDcalc.Sources.AddCube(Cub);
// Create formulas table
FormulasTable := MDcalc.FormulasTable;
TableForFormulas := FormulasTable.Create;
(TableForFormulas As IMetabaseObject).Save;
FormulasTable.Attach(TableForFormulas);
// Create parameters for multidimensional calculation
Params := (dMd As IMetabaseObject).Params;
param := Params.Add;
param.Id := "PARAM";
param.DataType := DbDataType.Integer;
// Set control of parameters by nested objects
DictParam := Mb.ItemById("PARAM_DICT");
objContrl := Params.ControlInfo.FindByKey(DictParam.Key);
objContrl.Item(0).Expression.AsString := ":PARAM";
// Set control of parameters
dim := DictParam.Bind As IDimensionModel;
sel := MDcalc.SelectionControl;
sel.Item(1).ControllingDim := dim;
sel.Item(1).Expression.AsString := "FIRST.ID";
// Save calculation
(dMd As IMetabaseObject).Save;
End Sub Main;
After executing the example multidimensional calculation on DB server with the the MDCALC identifier is created in the repository root. The CUBE_SOUR cube serves as a source cube, the CUBE_DEST as a destination cube. In multidimensional calculation the parameter, which influences parameter of destination cube dictionary, is created. A controlling dimension is determined for the source cube.
See also: