Electronic Data Interchange (EDI)
Electronic Data Interchange (EDI) is a data structure used to support automated data exchange between businesses. For example, it can be used to exchange billing information for energy usage.
It is defined here: http://www.edibasics.com/edi-resources/document-standards/
The data format this connector type supports is a special type of delimited text and as such it supports the same parameters as Text connectors do. It is composed of a number of records called "segments" with varying fields called "elements". For the purpose of this explanation they'll be referred to as records and fields. Which fields are present is determined by the first field's value, but more than one leading value may be required to determine how to process the information. Another way of saying this is that the first field determines the record type (the structure of the data), but additional fields may be required to determine the transaction type (a data event that usually triggers an operation).
Another complexity of this data is that records are related to previous records of different types in a hierarchy, so while one particular source record invokes a transaction, the transaction may require more than one record to be performed.
Example
VAL|13< OP|MULT|4<
In this case the field delimiter is "|" and the record delimiter is "<". The record delimiter in EDI is actually a terminator, and as such the ignoreLastRecordIfEmpty connector paramter should always be set to true.
The first record has a prefix of "VAL" for value (note: this is made up for the example). The second record has a prefix of "OP" for operation.
The connector configuration might look like this:
{ nestedRecords: [ { prefixes : ['VAL'], startPos : 4, endPos : 5 }, { prefixes : ['OP'], startPos : 1, endPos : 3, migrateTo : 'result_table', bufferedPrefixes : [['VAL']] } ] }
The "nestedRecords" JSON array defines how records are related, and which fields in connector fields define them. Each JSON object in the array defines a record type. Record types should have higher position numbers than record types that buffer them.
The record type object has five attributes. If the "migrateTo" parameter is present, it also represents a transaction. The parameters are:
- prefixes - an array of field values starting from the first that identify this record type.
- startPos - the position of the first connector field representing a field in a record of this type.
- endPos - the position of the last connector field representing a field in a record of this type.
- migrateTo - for a transaction, which table should be updated.
- bufferedPrefixes - an array of arrays representing the prefixes for other record types that are needed for this transaction.
When the transaction occurs, the buffered records for that type are appended to the record of that type in order of position creating one long record. That record is processed as any other delimited text record would be, using the specified connector fields. Note: if there are more connector fields than values in a record, values will be added to the record so that the connector fields always align with the record's fields. It is also valid to have more than one record type with a migrateTo attribute so long as they all form valid transactions, but it is not valid to use the same prefixes for more than one record type.