ICalcBlock.StubOut

Syntax

StubOut: IVariableStub;

Description

The StubOut property determines the data consumer, to which formula calculation result is to be recorded.

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier and two standard cubes with the CUBE and SOURCE_CUBE identifiers. The calculation algorithm should contain a calculation block, the cubes should contain calendar dimensions.

Add links to the Algo, Cubes, Metabase system assemblies. Add links to the assemblies required for working with calculation algorithms.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    Algo, CalcBlock: ICalcObject;
    List: ICalcObjectsList;
    CalcAlgo: ICalcAlgorithm;
    Block: ICalcBlock;
    StandCube, SourceCube: IStandardCube;
    Stub: IVariableStub;
    IteratorModel: ICalcBlockIteratorModel;
    IteratorStub: ICalcBlockIteratorStub;
    CountStubs, i: Integer;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Get list of calculation algorithm objects
    List := CalcAlgo.Items;
    // Get calculation block
    CalcBlock := List.Item(0);
    Block := CalcBlock As ICalcBlock;
    // Get first cube
    StandCube := MB.ItemById("CUBE").Edit As IStandardCube;
    Stub := StandCube As IVariableStub;
    // Set cube as data consumer
    Block.StubOut := Stub;
    // Get second cube
    SourceCube := MB.ItemById("SOURCE_CUBE").Edit As IStandardCube;
    Stub := SourceCube As IVariableStub;
    // Set cube as data source
    Block.StubsIn.Add(Stub);
    // Determine calendar dimension of data source as a regular dimension
    Block.UseCalendarAsStubDimension(Stub) := True;
    // Set up links between data source dimensions and data consumer dimensions by attribute identifiers
    IteratorModel := Block.EditIteratorModel;
    CountStubs := IteratorModel.Stubs.Count;
    For i := 0 To CountStubs-1 Do
        IteratorStub := IteratorModel.Stubs.Item(i);
        // Check use of links in formulas
        If IteratorStub.HasUsedFormulesForLinkById = False  Then
            // Set link between dimensions by attribute identifiers
            IteratorStub.LinkById;
        End If;
    End For;
    IteratorModel.Save;
    // Save changes in calculation block
    Block.SaveObject;
End Sub UserProc;

After executing the example, standard cubes are set as data source and data consumer for the calculation block. Calendar dimensions will be used as regular dimensions. A link by attribute identifiers is set up for all data source and data consumer dimensions if it not used in formulas.

See also:

ICalcBlock