GetStubSel(Stub: IVariableStub, [Full: Boolean = false,] [ParamValues: IMetabaseObjectParamValues = Null]): IDimSelectionSet;
Stub. Data source
Full. Method of getting data source dimensions.
ParamValues. Collection of dimension parameter values.
The GetStubSel method returns data source dimensions list.
Available values of the Full parameter:
True. Controlling and controlled dimensions contain all available element sets taking into account the parameterization settings.
IMPORTANT. The use of the parameter with the True value may result in the reduced performance and long method execution depending on the number of dimension elements.
False. Default. Controlling and controlled dimensions contain element sets without taking into account the parameterization settings. In this case, controlled dimensions will be empty until the controlling dimension element selection is applied.
The ParamValues parameter is set to Null by default.
When the method is used, dimension sorting is applied for the data source: first, controlling dimensions are returned, then controlled dimensions are returned.
To manage selections of controlling and controlled dimensions:
Set the IMsSelectionControl.IsActive property to True to manage parameters of data source dimensions.
Get the list of dimensions using the IMsSelectionControl.GetStubSel method.
Set controlling dimension selection using the DimSelectionSetFactory class and the IDimSelectionSetFactory.CreateDimSelectionSet, IDimSelectionSet.Add, IDimSelection.SelectElement methods.
Apply selection of controlling dimension elements to change the dimension element set using the IMsSelectionControl.Apply method.
After this, the controlled dimension element set is changed based on the controlling dimension element selection.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier, which contains controlling dimensions. For example, the A dimension contains a parameter, and the B dimension controls the A dimension using the configured link, in which the attribute is set, which sends value to the A dimension parameter is set.
Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Stub: IVariableStub;
SelControl: IMsSelectionControl;
SelSet, SelSetNew: IDimSelectionSet;
Sel: IDimSelection;
Factory: IDimSelectionSetFactory;
Begin
MB := MetabaseClass.Active;
// Get standard cube
Stub := MB.ItemById("STD_CUBE").Bind As IVariableStub;
// Create a class to manage dimension parameters
SelControl := New MsSelectionControl.Create;
SelControl.IsActive := True;
Debug.WriteLine("Before applying controlling dimension element selection:");
// Get list of all data source dimension elements
SelSet := SelControl.GetStubSel(Stub, True);
// Display dimension names and elements list in the console
PrintSelectionSet(SelSet);
// Set controlling dimension selection
Factory := New DimSelectionSetFactory.Create;
SelSetNew := Factory.CreateDimSelectionSet;
Sel := SelSetNew.Add(SelSet.Item(0).Dimension);
// Select the second and the fourth elements
Sel.SelectElement(1, False);
Sel.SelectElement(3, False);
// Apply the specified selection for controlled dimensions
SelSetNew := SelControl.Apply(Stub, SelSetNew);
Debug.WriteLine("After applying controlling dimension element selection:");
// Display dimension names and elements list in the console
PrintSelectionSet(SelSetNew);
End Sub UserProc;
Sub PrintSelectionSet(SelSet: IDimSelectionSet);
Var
Copy: IDimSelectionSet;
Sel: IDimSelection;
Begin
Copy := SelSet.CreateCopy;
For Each Sel In Copy Do
Sel.SelectAll;
Debug.WriteLine("Dimension: " + Sel.Dimension.Name + "," + " Elements: " + Sel.ToString);
End For;
Debug.WriteLine("");
End Sub PrintSelectionSet;
After executing the example, controlling dimension elements are selected, and controlled dimension element sets are changed. The console displays names of all cube dimensions and elements lists for each dimension before and after applying controlled dimension selection.
See also: