Creating Composite Calendar Dictionary

Composite calendar dictionary is integration of several calendar dictionaries with various frequency. If a calendar dictionary has only yearly frequency, another one has quarterly and monthly, composite calendar dictionary based on data of these dictionaries contains yearly, quarterly and monthly frequency.

Executing the example requires that the repository contains calendar dictionaries with the CALEND_1 and CALEND_2 identifiers.

Sub Main;

Var

createInfo: IMetabaseObjectCreateInfo;

calendar: ICompoundCalendar;

Des: IMetabaseObjectDescriptor;

Mb: IMetabase;

objCalend: IMetabaseObject;

Source: ICompoundDimensionSource;

dimModel: IDimensionModel;

dimModel1: IDimensionModel;

Cinstance: ICompoundDimensionInstance;

Instance: IDimInstance;

el: IDimElements;

i, j: Integer;

Begin

Mb := MetabaseClass.Active;

createInfo := Mb.CreateCreateInfo;

createInfo.ClassId := MetabaseObjectClass.KE_CLASS_COMPOUNDCLNDIM;

createInfo.Name := "CompoundCalendar";

createInfo.Id := createInfo.Name;

createInfo.Permanent := True;

createInfo.Parent := Mb.Root;

Des := mb.CreateObject(createInfo);

objCalend := Des.Edit;

calendar := objCalend As ICompoundCalendar;

source := calendar.Sources.Add(1);

dimModel := Mb.ItemById("CALEND_1").Bind As IDimensionModel;

source.Dimensions.Add(dimModel);

source := calendar.Sources.Add(2);

dimModel1 := Mb.ItemById("CALEND_2").Bind As IDimensionModel;

source.Dimensions.Add(dimModel1);

objCalend.Save;

Cinstance := objCalend.Open(Null) As ICompoundDimensionInstance;

Instance := Cinstance As IDimInstance;

memo1.Lines.Add("Number of elements" + Instance.Elements.Count.ToString);

el := Instance.Elements;

j := Instance.Attributes.FindById("NAME").Attribute.Key;

For i := 0 To el.Count - 1 Do

Debug.WriteLine("Element " + (i + 1).ToString + ": " + (el.AttributeValue(i, j) As String));

End For;

End Sub Main;

After executing the example repository root catalog contains a composite calendar dictionary collating the CALEND_1 and CALEND_2 dictionaries. The console window shows names of composite dictionary elements.

See also:

Examples