Value: Variant;
The Value property determines value of the attribute, by which elements are filtered.
If the Value property is not determined, correct work of filter is impossible.
If Value contains the values array of the Variant type and the IRdsDictionaryFilterCondition.Operation property has the value:
RdsConditionOperation.Equal. The In condition is applied to the filter, that is, the attribute value is contained in the Value array.
RdsConditionOperation.NotEqual. The NotIn condition is applied for the filter, that is, the attribute value is not contained in the Value array.
Executing the example requires that the repository contains an MDM dictionary with the EXP_DICT identifier.
A text file C:\Data_out.txt must be created in the file system.
Add links to the Metabase, Rds, Dt system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
dictObj: IMetabaseObject;
Dict: IRdsDictionary;
sExport: IMetaRdsExportSchema;
i: Integer;
dictAts: IRdsAttributes;
Attr: IRdsAttribute;
attrMap: IRdsExportSchemaAttribute;
dictFilter: IRdsDictionaryFilterConditions;
Cond: IRdsDictionaryFilterCondition;
textCons: IDtTextConsumer;
dictInst: IRdsDictionaryInstance;
Begin
Mb := MetabaseClass.Active;
// Get MDM dictionary
dictObj := Mb.ItemById("EXP_DICT").Edit;
Dict := dictObj As IRdsDictionary;
// Create a new export scheme
sExport := Dict.ExportSchemas.Add As IMetaRdsExportSchema;
// Bind dictionary attributes to the consumer fields
dictAts := Dict.Attributes;
For i := 0 To dictAts.Count - 1 Do
Attr := dictAts.Item(i);
attrMap := sExport.AddMapping;
attrMap.Attribute := Attr;
attrMap.FieldName := Attr.Id;
End For;
// Determine that the consumer must be cleared before export
sExport.ClearBeforeExport := True;
// Add filtering
dictFilter := sExport.Filter;
Attr := dictAts.FindById("KEY");
Cond := dictFilter.Add(Attr);
Cond.Value := 0;
Cond.Operation := RdsConditionOperation.GreaterOrEqual;
Cond := dictFilter.Add(Attr);
Cond.Value := 15;
Cond.Operation := RdsConditionOperation.LesserOrEqual;
// Set up data consumer: text file
textCons := New DtTextConsumer.Create;
textCons.File := "c:\Data_out.txt";
textCons.WriteHeader := True;
textCons.RowDelimiter := #13 + #10;
textCons.DelimitedColumnDelimiter := #9;
textCons.DelimitedTextQualifier := "'";
sExport.Consumer := textCons;
// Save the dictionary
dictObj.Save;
// Export
dictInst := dictObj.Open(Null) As IRdsDictionaryInstance;
dictInst.ExportData(sExport);
End Sub UserProc;
After executing the example, elements with the key values in the range [0; 15] are exported from the dictionary to the file C:\Data_out.txt.
See also: