IMDCalculationInstance.CreateFormulasConverter

Syntax

CreateFormulasConverter(Cube: ICalculatedCubeInstance): IMDCalculationFormulasConverter;

Parameters

Cube. Calculated cube, to which formulas from multidimensional calculation must be converted.

Description

The CreateFormulasConverter method creates an object that is used to convert formulas from multidimensional calculation into calculated cube.

Example

Executing the example requires that the repository contains multidimensional calculation on DB server with the MDCalc identifier and a calculated cube with the CalcCube identifier. The multidimensional calculation and the calculated cube must be based on equal data sources.

Sub UserProc;
Var
    MB: IMetabase;
    CalcCubeInst: ICalculatedCubeInstance;
    MDCalcInst: IMDCalculationInstance;
    FConverter: IMDCalculationFormulasConverter;
    bStruct: Boolean = False;
    StructError: String;
Begin
    MB := MetabaseClass.Active;
    CalcCubeInst := MB.ItemById("CalcCube").Open(NullAs ICalculatedCubeInstance;
    MDCalcInst := MB.ItemById("MDCalc").Open(NullAs IMDCalculationInstance;
    FConverter := MDCalcInst.CreateFormulasConverter(CalcCubeInst);
   FConverter.CorrectSourceFormulas := True;
    Try
        //Check correspondence of multidimensional calculation structures
        //and calculated cube
        FConverter.ValidateStructure;
        bStruct := True;
    Except On e: Exception Do
        StructError := e.Message;
    End Try;
    If Not bStruct Then
        Debug.WriteLine(Structures of multidimensional calculation and calculated cube are not compatible);
        Debug.WriteLine(Error:  + StructError);
    Else
        //Convert formulas
        FConverter.BatchMode := ConvertBatchMode.Update;
        FConverter.Convert;
        CalcCubeInst.SaveFormulas;
    End If;
End Sub UserProc;

On executing the example structures of multidimensional calculation and calculated cube are checked for correspondence. If the structures are similar, formulas in the calculated cube will be updated according to the formulas of the multidimensional calculation. Formulas of the multidimensional calculation will be adjusted before converting to the calculated cube.

See also:

IMDCalculationInstance