How Do I Split a Data Element? (Magic xpi 4.13)
To break down a single data element into a multi-occurrence Destination element (the opposite of the unification of data elements procedure), pre-process the Source data in a flow to create flat file data containing the multi-occurrence data. Then map the flat file to the Destination compound to create the required multi-occurrence Destination element.
The solution requires a loop with a variable that controls the number of iterations. You should add elements to the flat file in each iteration by defining the Flat File Destination in Append mode. Alternatively, you can use local ODS arrays.
To split a data element:
-
Drag a Data Mapper utility to the flow area.
-
Define the Source as XML type and the Destination as a variable. The calculations will be executed on this variable to prevent the repeated reading of the XML for the same data.
-
Map the element of the Source that holds the alphanumeric value that you want to split into the Alpha variable.
-
Define a Flow Data step that updates the counter.
-
Define a new Data Mapper step to handle the split operation. The Source is empty, and the Destination is a Flat File type with Append mode.
-
Define a Destination expression that extracts the required data, as shown below. For example:
mid ( F.StringToProcess ,F.StartLocation ,F.LineSize )
![](/PublicKnowledge/servlet/rtaImage?eid=ka23z000000H0LC&feoid=00ND0000005rAjf&refid=0EM3z000007lCpY)
-
The final step is a GoTo command for the Calculate (Flow Data) step, with an exit condition (F.Total). In the image below, the Loop exit condition is:
F.LoopCounter < F.Total
![](/PublicKnowledge/servlet/rtaImage?eid=ka23z000000H0LC&feoid=00ND0000005rAjf&refid=0EM3z000007lCpZ)