OrganizeLevels;
The OrganizeLevels method automatically creates levels in accordance with hierarchy of fact dictionary elements.
Created levels will have the following parameters:
Level identifiers are generated as follows: LEVEL1, LEVEL2...LEVELn.
Level names are generated as follows: Level1, Level2...Leveln
Executing the example requires a standard cube with the STD_CUBE identifier in the repository.
Sub UserProc;
Var
MB: IMetabase;
Cube: IStandardCube;
CustDim: ICustomDimension;
TreeElements: ICustomDimTree;
v: Variant;
Begin
MB := MetabaseClass.Active;
Cube := MB.ItemById("STD_CUBE").Edit As IStandardCube;
CustDim := Cube.FactDimension.Dimension As ICustomDimension;
TreeElements := CustDim.Tree;
CustDim.Elements.Clear;
//Add new elements
v := TreeElements.Add(Null);
TreeElements.Name(v) := "Element 1";
v := TreeElements.Add(v);
TreeElements.Name(v) := "Element 1_1";
//Create levels
CustDim.OrganizeLevels;
//Save
(Cube As IMetabaseObject).Save;
End Sub UserProc;
After executing the example element structure is changed in fact dimension. Two dimension levels are created in accordance with two levels of element hierarchy.
See also: