Refresh(Dimension: IMetabaseObjectDescriptor; [Instance: IDimInstance = Null]): Boolean;
Dimension. The dimension included to the cube, which is a data source.
Instance. The dictionary instance to work with elements.
The Refresh method updates slice dimension.
To get dictionary instance (the Instance parameter) and work with elements, use the IMetabaseObjectDescriptor.Open method and cast the dictionary to the IDimInstance interface.
To execute the example:
Create a regular report.
Add a cube as a data source containing MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers. The MDM dictionaries contain attributes with the NAME and ORD identifiers.
Add a slice to data area .
Drag the added slice to the report sheet using Drag&Drop.
Add two controls for MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers.
Add the Metabase, Report, Rds, Dimensions system assemblies in units.
Create the first unit to work with elements of the MDM dictionary with the D_FACTS identifier:
Sub UserProc;
Var
Report: IPRxReport;
MB: IMetabase;
MObj1: IMetabaseObject;
DtSources: IPrxDataSources;
DtSource: IPrxDataSource;
DimI: IDimInstance;
Str: String;
Key, i: Integer;
Rds: IRdsDictionaryInstance;
Data: IRdsDictionaryElementData;
Begin
// Get active regular report
Report := PrxReport.ActiveReport;
MB := Report.MetabaseObject.Metabase;
DtSources := Report.DataSources;
DtSource := DtSources.Item(0);
// Get MDM dictionary with the specified identifier
MObj1 := MB.ItemByIdNamespace("D_FACTS", 159).Bind;
// Open MDM dictionary for edit
DimI := MObj1.Open(Null) As IDimInstance;
Rds := DimI As IRdsDictionaryInstance;
// Create element containing attribute data of the MDM dictionary element
Data := Rds.CreateElementData;
// Add name to the attribute with the NAME identifier
Key := Rds.Attributes.FindById("NAME").Attribute.Key;
Str := "Element " + Rds.Elements.Count.ToString;
Data.Attribute(Key) := Str;
// Add value to the attribute with the ORD identifier
Key := Rds.Attributes.FindById("ORD").Attribute.Key;
i := Rds.Elements.Count;
Data.Attribute(Key) := i;
// Add a created element to MDM dictionary
Rds.Insert(Rds.Elements.Root, Data);
// Create MDM dictionary instance
DimI := MObj1.Open(Null) As IDimInstance;
// Add the second element by analogy
Data := Rds.CreateElementData;
Key := Rds.Attributes.FindById("NAME").Attribute.Key;
Str := "Element " + Rds.Elements.Count.ToString;
Data.Attribute(Key) := Str;
Key := Rds.Attributes.FindById("ORD").Attribute.Key;
i := Rds.Elements.Count;
Data.Attribute(Key) := i;
Rds.Insert(Rds.Elements.Root, Data);
// Refresh dimension in the report
DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor, DimI);
End Sub UserProc;
Connect the first unit to the report.
Add text with hyperlink in order to execute procedure or function. Select the first unit connected previously to the report.
Create the second unit to work with elements of the MDM dictionary with the DIC_SOURCE identifier:
Sub UserProc;
Var
Report: IPRxReport;
MB: IMetabase;
MObj1: IMetabaseObject;
DtSources: IPrxDataSources;
DtSource: IPrxDataSource;
DimI: IDimInstance;
Str: String;
Key, i: Integer;
Rds: IRdsDictionaryInstance;
Data: IRdsDictionaryElementData;
Begin
// Get active regular report
Report := PrxReport.ActiveReport;
MB := Report.MetabaseObject.Metabase;
DtSources := Report.DataSources;
DtSource := DtSources.Item(0);
// Get MDM dictionary with the specified identifier
MObj1 := MB.ItemByIdNamespace("DIC_SOURCE", 159).Bind;
// Open MDM dictionary for edit
DimI := MObj1.Open(Null) As IDimInstance;
Rds := DimI As IRdsDictionaryInstance;
// Create element containing attribute data of the MDM dictionary element
Data := Rds.CreateElementData;
// Add name to the attribute with the NAME identifier
Key := Rds.Attributes.FindById("NAME").Attribute.Key;
Str := "Element " + Rds.Elements.Count.ToString;
Data.Attribute(Key) := Str;
// Add value to the attribute with the ORD identifier
Key := Rds.Attributes.FindById("ORD").Attribute.Key;
i := Rds.Elements.Count;
Data.Attribute(Key) := i;
// Add a created element to MDM dictionary
Rds.Insert(Rds.Elements.Root, Data);
// Create MDM dictionary instance
DimI := MObj1.Open(Null) As IDimInstance;
// Add the second element by analogy
Data := Rds.CreateElementData;
Key := Rds.Attributes.FindById("NAME").Attribute.Key;
Str := "Element " + Rds.Elements.Count.ToString;
Data.Attribute(Key) := Str;
Key := Rds.Attributes.FindById("ORD").Attribute.Key;
i := Rds.Elements.Count;
Data.Attribute(Key) := i;
Rds.Insert(Rds.Elements.Root, Data);
// Refresh dimension in the report
DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor);
End Sub UserProc;
Connect the second unit to the report.
Add text with hyperlink in order to execute procedure or function. Select the second unit connected previously to the report.
In regular report, after clicking the first hyperlink, one element is added to the MDM dictionary with the D_FACTS identifier, and after clicking the second hyperlink two elements are added to the MDM dictionary with the DIC_SOURCE identifier. The difference in results is that on refreshing dimension in report, the dictionary instance to work with the DimI elements (the Instance parameter) is set and it was not set for the second unit. New elements of MDM dictionaries are displayed in the report controls.
See also: