From CSV to EDIFACT with Talend Data Mapper


This blog shows how to create a EDIFACT message from a CSV file with Talend.
The tutorial describes how to first create an XML from an existing EDI message and next how to transform the CSV input to a EDI message with Talend Data Mapper (from XML to EDI).


To start you need the following three items.

  1. An example of the to be created EDI message. If this is not available the full layout of the messasge can be found on http://www.truugo.com/edifact. Here you can find the message (f.i. INVOIC) and the version (f.i. D96a)
  2. An example of the CSV file or a functional description of the records / fields
  3. A description of the transformation rules from CSV to EDI

 


The project “From CSV to EDI” consists of the following steps:

  1. Create job: Edifact to XML
  2. Create structure for the EDI output
  3. Create structure for the XML input
  4. Mapping input to output
  5. Create job: CSV to XML
  6. Create job: XML to EDI

Step 1: Create job: Edifact to XML
The first thing we need to do is to make a XML message from the EDI. We will need the structure of this XML message in the Data Mapper and for composing the message in the CSV to XML job. This can easily be done by the tEDIFACTtoXML component.

EDItoXML

The input of this job is the EDI message and the output will be an XML structure

Step 2: Create structure for the EDI output
The next thing to do is to create the output structure for the EDI message. To do this you need to create a new structure for the transaction. Next you import the EDI message and you will build the structure of the transaction. When the structure is created you can validate the structure/segments/ elements by checking if the appropriate line (and part of the line) is highlighted in the validation window. For the appropriate working of the structure it is essential to get the right Sequence ID in the segments. You can find this f.i. on: https://www.stylusstudio.com/edifact/D96A/messages.htm

OutputStructureEDI

After we have created the output structure to be used in the Data Mapper we will do the same for the input.

Step 3: Create structure for the XML input
The things we need to do here is almost similar to step 2, except for the part about Sequence ID. As this is an input description this is not important here. Instead of this there is another thing to do. You will have to create the structure the same as the EDI output. This means that you will have to specify all the loops and their minimum and maximum occurs.

InputstructureXML

Step 4: Mapping input to output
After the creation of the XML input definition and the EDI output it is time to connect input and output in the Talend Data Mapper.

Mapping
We will have to drag and connect all of the items of the input one to one to the ones in the output. This can be done on the highest level include all the underlying fields but this only works when the underlying structures and names are all exact the same.

Step 5: Create job: CSV to XML
Now we have the input, the output and the mapping between them it’s time to create the job that will feed this structure with the data from the CSV file. What we will do is to handle the segments of the EDI message in the same sequence as the final output EDI.

CSVtoXML

This will create the appropriate message as tAdvancedFileOutputXML will append all the segments to one output XML. This file in the input for the last job: XML to EDI.

tAdvancedFileOutputXML

Step 6: Create job: XML to EDI
The last job XML to EDI will use the XML file created by the CSV to XML job and tHMap uses the mapping structure to format and write the final EDI to tFileOutputRaw. The file is ready to send to the recieving EDI client.

XMLtoEDI


This tutorial was created using Talend Data Fabric version 6.0.1

Author: Paul Molenaar

Paul is a data management consultant with many years of experience in data integration and business intelligence. Recently his focus shifted forewards towards Internet of Things and Big Data.

XSed is a value added reseller for Talend Open Data Solutions.

Website: http://www.xsed.nl

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *

FacebookTwitterGoogle+RSS