Handling Multiple Consecutive Data Elements

Handling Multiple Consecutive Data Elements

EDI segments often allow the use of multiple consecutive elements of the same name. For example, this is applicable to the N2 segment of the "850 - PURCHASE ORDER" transaction set of the X12 standard. According to the specification, the N2 segment allows for two consecutive alphanumeric "Name" fields (one mandatory and one optional):

When you create or modify an EDI configuration, there are two possibilities to handle such data elements, as shown below.

In this approach, you create multiple occurrences of the data element in the segment file. In this case, a new node will appear on the mapping for each occurrence of the data element. Consider this configuration:

<Segmentname="N2"info="Additional Name Information"><Dataref="F93"nodeName="F93_1"/><Dataref="F93"minOccurs="0"nodeName="F93_2"/></Segment>

On the mapping, this configuration creates two separate F93 nodes, each corresponding to an occurrence of F93:

X12 EDI component with separate F93 nodes

Using this approach is suitable when every occurrence of the data element is meaningful by itself and, consequently, you want a separate node to appear for it on the mapping.

Approach 2: Create a single node for all occurrences of the data element

In this approach, you treat all occurrences of the data element as one single node. To do this, add the mergedEntries attribute to the corresponding data element. In the code listing below, the mergedEntries attribute of data element F93 is set to "2". This allows for two consecutive occurrences of this field in the EDI instance file.

<Segmentname="N2"info="Additional Name Information"><Dataref="F93"mergedEntries="2"/></Segment>

On the mapping, the node corresponding to the F93 data element will be displayed as a single node:

X12 EDI component with separate F93 nodes

Mapping data from a data element which has merged entries will create multiple duplicate elements on the target side, if the source EDI file contains multiple (not empty) occurrences of this element. For example, let's consider a source EDI file where the N2 segment contains two consecutive occurrences of F93. The first occurrence is "Michelle Butler" and the second is "Mrs".

N2+Michelle Butler+Mrs+'

Mapping data from such an EDI file would create, on the target side, the following output (notice the duplicate occurrences of <ContactName>):

Using this approach is suitable when each occurrence of the data element is not meaningful by itself, and you do not want a separate node to appear on the mapping for each occurrence. For example, a data element with multiple occurrences may store multiple line entries that make up an address. For such cases, the "merged entries" approach might be more useful than having individual nodes for each address line.

Some configuration files supplied by default with MapForce use merged entries, and therefore, only one node appears on the mapping for multiple consecutive occurrences of a data element. If you need separate nodes for each occurrence of the data element, this can be achieved by customizing the EDI configuration. For an example, see Splitting Merged Entries into Separate Nodes.