Consider the example of creating multidimensional calculation on database server using the Fore and Fore.NET language. To start creation, the following objects must be in repository:
A database with the DB identifier.
Two standard cubes with the STD_SOURCE and STD_DESTINATION identifiers.
The cubes must have a calendar dimension with the CALENDAR identifier in its structure.
The following example creates a new object that is Multidimensional Calculation on DB Server in the repository root and sets up its parameters:
The database is specified.
The source cube and consumer cube are set.
Calendar dimensions are fixed in the structure of cubes.
To execute the examples, add links to the Cubes, Db, Dimensions and Metabase system assemblies. Write the corresponding Imports strings for the Fore.NET example.
Sub CreateMDCalculation;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
MDCalc: IMDCalculation;
Cube: ICubeModel;
Source: IMDCalculationSource;
Destination: IMDCalculationDestination;
FormulasTable: IMDCalculationFormulasTable;
TableForFormulas: ITable;
SourceSlice, DestinationSlice: IMDCalculationSlice;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MDCALCULATION;
CrInfo.Id := "New_MDCalculation";
CrInfo.Name := "Multidimensional calculation on server";
CrInfo.Parent := MB.Root;
MObj := MB.CreateObject(CrInfo).Edit;
MDCalc := MObj As IMDCalculation;
//Specify database
MDCalc.Database := MB.ItemById("DB").Bind As IDatabase;
//Specify source cube
Cube := MB.ItemById("STD_SOURCE").Bind As ICubeModel;
Source := MDCalc.Sources.AddCube(Cube);
SourceSlice := Source.Slices.FindById("CALENDAR");
SourceSlice.FixType := MDCalculationSliceFixType.Fixed;
//Specify destination cube
Destination := MDCalc.Destination;
Destination.SetCube(MB.ItemById("STD_DESTINATION").Bind As ICubeModel);
//Fix calendar dimensions
DestinationSlice := Destination.Slices.FindById("CALENDAR");
DestinationSlice.FixType := MDCalculationSliceFixType.Fixed;
SourceSlice.Fixed.Mapping := DestinationSlice;
//Create a new formulas table
FormulasTable := MDCalc.FormulasTable;
TableForFormulas := FormulasTable.Create;
FormulasTable.Attach(TableForFormulas);
MObj.Save;
End Sub CreateMDCalculation;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;
Sub CreateMDCalculation(MB: IMetabase);
Var
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
MDCalc: IMDCalculation;
Cube: ICubeModel;
Source: IMDCalculationSource;
Destination: IMDCalculationDestination;
FormulasTable: IMDCalculationFormulasTable;
TableForFormulas: ITable;
SourceSlice, DestinationSlice: IMDCalculationSlice;
Begin
CrInfo := MB.CreateCreateInfo();
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MDCALCULATION As Integer;
CrInfo.Id := "New_MDCalculation";
CrInfo.Name := "Multidimensional calculation on server";
CrInfo.Parent := MB.Root;
MObj := MB.CreateObject(CrInfo).Edit();
MDCalc := MObj As IMDCalculation;
//Specify database
MDCalc.Database := MB.ItemById["DB"].Bind() As IDatabase;
//Specify source cube
Cube := MB.ItemById["STD_SOURCE"].Bind() As ICubeModel;
Source := MDCalc.Sources.AddCube(Cube);
SourceSlice := Source.Slices.FindById("CALENDAR");
SourceSlice.FixType := MDCalculationSliceFixType.csftFixed;
//Specify destination cube
Destination := MDCalc.Destination;
Destination.SetCube(MB.ItemById["STD_DESTINATION"].Bind() As ICubeModel);
//Fix calendar dimensions
DestinationSlice := Destination.Slices.FindById("CALENDAR");
DestinationSlice.FixType := MDCalculationSliceFixType.csftFixed;
SourceSlice.Fixed.Mapping := DestinationSlice;
//Create a new formulas table
FormulasTable := MDCalc.FormulasTable;
TableForFormulas := FormulasTable.Create(Null);
FormulasTable.Attach(TableForFormulas);
MObj.Save();
End Sub;
See also: