IMDCalculationSources.AddCube

Syntax

AddCube(Cube: ICubeModel): IMDCalculationSource;

Parameters

Cube - cube that must be added to the list of data sources of multidimensional calculation on DB server.

Description

The AddCube method adds a cube to the list of data sources of multidimensional calculation on DB server. When a cube is added, slices for each cube dimension are created automatically; factors, linked with cube facts, are also created.

Example

Executing the example requires that the repository contains a database with the MDBD identifier and two standard cubes CUBE_INPUT and CUBE_OUTPUT. These cubes are based on the tables stored in this database.

Sub Main;

Var

MB: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

MDCalc: IMDCalculation;

Cube: ICubeModel;

Source: IMDCalculationSource;

Destination: IMDCalculationDestination;

FormulasTable: IMDCalculationFormulasTable;

TableForFormulas: ITable;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MDCALCULATION;

CrInfo.Id := "MDCALC_1";

CrInfo.Name := Multidimensional calculation on server;

CrInfo.Parent := Null;

Debug.WriteLine(CrInfo.Id);

MObj := MB.CreateObject(CrInfo).Edit;

MDCalc := MObj As IMDCalculation;

//Add DB

MDCalc.Database := MB.ItemById("MDBD").Bind As IDatabase;

//Indicate source cube

Cube := MB.ItemById("CUBE_INPUT").Bind As ICubeModel;

Source := MDCalc.Sources.AddCube(Cube);

//Indicate destination cube

Destination := MDCalc.Destination;

Destination.SetCube(MB.ItemById("CUBE_OUTPUT").Bind As ICubeModel);

//Create new formula table

FormulasTable := MDCalc.FormulasTable;

TableForFormulas := FormulasTable.Create;

FormulasTable.Attach(TableForFormulas);

MObj.Save;

End Sub Main;

After executing the example the Multidimensional Calculation on DB Server object is created in the repository root. One source cube and one destination cube are determined, a new formulas table is created.

See also:

IMDCalculationSources