Create EDI related transformations

Last modified by Erik Bakker on 2024/09/03 08:01

This micro-learning will focus the tranformation from EDI to an XML message. EDI (Electronic Data Interchange) is a very specific format of a message that can be interpreted by some systems. Rather than providing XML tags or curly JSON brackets, you will find a flat file that is very well organized but uses lots or abbreviations or tags to identify entities and attributes in the message. This microlearning will explain more around these structures and how to create such EDI messages when you have an XML prepared.

Should you have any questions, please get in touch with academy@emagiz.com.

1. Prerequisites

  • Intermediate knowledge of the eMagiz platform
  • Good working experience in the Create phase and transformations.

2. Key concepts

An example of an EDI message is listed below. Each line starts with a tag that indicates the meaning of the line, and each message starts with fixed starting tags (UNA) and fixed ending tags (UNZ).

advanced-create-your-transformations-xml-2-edi-1.png

There are a lot of different versions of EDI each indicated with version id. A commonly used version is D96A, while versions D01B, D95A, D01A, etc exists. It's important to understand upfront what the version used is from the client, allthough the EDI message itself contains that information. The example above is a D01B version - see 3rd line. Within each version of EDI there is a specific type of data exchanged. Such as orders, invoices, confirmations, etc. In the example above this is an ORDERS message. Each of the version and data type combination has a specific message definition that is required to obtain in order to create the System Message.

3. Transforming XML to EDI messages (and vice versa)

The important part of generating the System Message for the EDI message is to create the XML structure of that specific EDI message type. The basis for the System definition is the XML structure that is generated from an EDI message or the structure to create an XML with. Using the EDI version and the message type inside the EDI message, components eMagiz will create the associated XML or EDI structure for you. Once you have this, you can then use that XML as the basis for your System Definition. This is the basis for the System Message validation in your process.

3.1 XML to EDI transformation model component

eMagiz has standard model components in the create phase available that can convert an EDI messages to an XML message. Below the screenshots of the model component. The important parameter here is which EDI version is used here.

advanced-create-your-transformations-xml-2-edi-2.png

Please note that you need to put the XML structure in the namespace of this transformation model component: urn:org.milyn.edi.unedifact.v41. The message type XML tag (DESADV, ORDER, etc) does not need to be prefixed.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|attribute()">
<xsl:copy>
<xsl:apply-templates select="node()|attribute()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(ancestor-or-self::DESADV)]">
<xsl:element name="ns:{local-name()}" namespace="urn:org.milyn.edi.unedifact.v41">
<xsl:apply-templates select="node()|attribute()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

3.2 EDI to XML transformation model component

As the previous section, but the other EDI model component needs to be selected. See below for a screenshot of that component.

advanced-create-your-transformations-xml-2-edi-3.png

3.3 File type best practise

  • In the event you receive an EDI, don't create any file to string alike transformation. Directly transform the file from EDI to XML

4. Key takeaways

eMagiz is able to transform messages from XML to EDI

  • Use the proper components to transform the message to the right EDI format
  • Validate the XML structure before it's transformed to an EDI message (outgoing)

5. Suggested Additional Readings