DetailTable: String;
The DetailTable property determines name of a table containing records for multiple values of a dictionary attribute.
The property is mandatory. It is also required to set the IRdsImportSchemaAttribute.DetailTableObject property for correct import.
Executing the example requires that the repository contains a table with the TABLE_EXP, TABLE_EXP_VALUE identifiers, an MDM repository with the MDM_REPO identifier containing an MDM dictionary with the MDM_DICTIONARY identifier. These objects should use the same database and satisfy the following requirements:
The MDM_DICTIONARY dictionary has an attribute with the ATTRIBUTE identifier that may have multiple values and is connected with another dictionary. The dictionary must not contain import scheme with the IMPORT_SCHEME identifier.
Identifiers and field types of the TABLE_EXP table and the MDM_DICTIONARY dictionary match.
The TABLE_EXP table must contain an integer field with the KEY_EXP identifier. The field is used to determine multiple values of attributes that are stored in the TABLE_EXP_VALUE table.
The TABLE_EXP_VALUE table contains multiple values of the ATTRIBUTE attribute, and mandatory integer fields with the KEYFIELD, VALUEFIELD, ORDERFIELD identifiers.
Add links to the Db, Metabase, Rds system assemblies.
Sub UserImport;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Import: IRdsImportSchemas;
SchemaImport: IRdsImportSchema;
Attrs: IRdsAttributes;
TableObj: IMetabaseObjectDescriptor;
Table: ITable;
SchemaImportAttr: IRdsImportSchemaAttribute;
DictInst: IRdsDictionaryInstance;
Begin
MB := MetabaseClass.Active;
// Get MDM dictionary
MObj := MB.ItemByIdNamespace("MDM_DICTIONARY_IMPORT", MB.ItemById("MDM_REPO").Key).Edit;
Dict := MObj As IRdsDictionary;
// Get MDM dictionary attributes
Attrs := Dict.Attributes;
// Create a new import scheme
Import := Dict.ImportSchemas;
SchemaImport := Import.Add;
SchemaImport.Id := "IMPORT_SCHEME";
SchemaImport.Name := Import scheme #1;
// Set binding of MDM dictionary system attributes
SchemaImport.Mappings(Attrs.Key).FieldName := "KEY";
SchemaImport.Mappings(Attrs.Name).FieldName := "NAME";
SchemaImport.Mappings(Attrs.Order).FieldName := "ORD";
SchemaImport.Mappings(Attrs.ParentKey).FieldName := "PARENT_KEY";
// Get the TABLE_EXP table
TableObj := MB.ItemById("TABLE_EXP");
Table := TableObj.Bind As ITable;
// Specify that import of system attribute values
// will be performed from the TABLE_EXP table
SchemaImport.TableObject := TableObj;
SchemaImport.TableName := Table.NativeName;
// Set binding of the attribute, which may take multiple values
SchemaImportAttr := SchemaImport.Mappings(Attrs.FindById("ATTRIBUTE"));
//Get the TABLE_EXP_VALUE table
TableObj := MB.ItemById("TABLE_EXP_VALUE");
// Specify, that import of multiple attribute values
// will be performed from the TABLE_EXP_VALUE table
Table := TableObj.Bind As ITable;
SchemaImportAttr.DetailTable := Table.NativeName;
SchemaImportAttr.DetailTableObject := TableObj;
// Set options of import of attribute multiple values
SchemaImportAttr.Attribute.Hidden := False;
SchemaImportAttr.FieldName := "KEY_EXP";
SchemaImportAttr.KeyField := "KEYFIELD";
SchemaImportAttr.ValueField := "VALUEFIELD";
SchemaImportAttr.OrderField := "ORDERFIELD";
// Save import scheme
MObj.Save;
// Run import
DictInst := Dict.Open(Null);
DictInst.ImportData(SchemaImport);
End Sub UserImport;
After executing the example a new import scheme is created in the MDM dictionary. Attribute values of the MDM_DICTIONARY dictionary are imported from same-name fields of the TABLE_EXP table. Multiple values of the ATTRIBUTE attribute are imported from the TABLE_EXP_VALUE table. Import will be executed.
See also: