ICalcBlockIteratorStub.LinkByLink

Syntax

LinkByLink;

Description

The LinkByLink method links data source dimensions with data consumer dimensions by linked attributes.

Comments

To check if links between data source dimensions and data consumer dimensions are used by linked attributes in formulas, use the ICalcBlockIteratorStub.HasUsedFormulesForLinkByLink method.

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.

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);
    // Set up links between data source dimensions and data consumer dimensions by linked attributes
    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.HasUsedFormulesForLinkByLink = False  Then
            // Set link between dimensions by linked attributes
            IteratorStub.LinkByLink;
        End If;
    End For;
    // 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. A link by linked attributes is set for all data source and data consumer dimensions if it is not used in formulas.

See also:

ICalcBlockIteratorStub