Header Ads Widget

Responsive Advertisement

Stylus studio convert edifact message

What is EDIFACT message?

EDIFACT (Electronic Data Interchange for Administration, Commerce, and Transport) is an international standard developed by the United Nations for electronic data interchange (EDI) between trading partners. It standardizes the format and structure of messages for various business transactions, such as orders, invoices, and shipping notices.

EDIFACT Message Structure

            Service String Advice     UNA   Conditional

     _____  Interchange Header        UNB   Mandatory

    |  ___  Functional Group Header   UNG   Conditional

    | |  _  Message Header            UNH   Mandatory

    | | |   User Data Segments              As required

    | | |_  Message Trailer           UNT   Mandatory

    | |___  Functional Group Trailer  UNE   Conditional

    |_____  Interchange Trailer       UNZ   Mandatory

 

Key Components of an EDIFACT Message

An EDIFACT message consists of segments, each of which contains data elements. Segments are grouped into sections, and sections form the entire message. Here are the main components:

  1. UNA (Service String Advice): Specifies the separators used in the message (optional).
  2. UNB (Interchange Header): Identifies the start of the message interchange and includes sender/receiver information.
  3. UNH (Message Header): Identifies the start of a message and contains message type and version.
  4. BGM (Beginning of Message): Provides the type and purpose of the message.
  5. DTM (Date/Time/Period): Specifies date and time information.
  6. NAD (Name and Address): Contains information about the parties involved.
  7. LIN (Line Item): Details about line items in the transaction.
  8. QTY (Quantity): Specifies quantities related to line items.
  9. UNS (Section Control): Separates logical sections within a message.
  10. UNT (Message Trailer): Marks the end of a message and provides a control count.
  11. UNZ (Interchange Trailer): Marks the end of an interchange.

Example EDIFACT Message

Here is a simplified example of an EDIFACT message for an order (ORDERS message type):

UNA:+.? '

UNB+UNOC:3+SENDERID+RECEIVERID+210101:1200+123456'

UNH+1+ORDERS:D:96A:UN:EAN008'

BGM+220+BKOD99+9'

DTM+137:20020910:102'

NAD+BY+5412345000176::9'

LIN+1++1234567890123:SRV'

QTY+47:1020:EA'

UNT+7+1'

UNZ+1+123456'

 

Detailed Breakdown of the Example

  1. UNA Segment:

UNA:+.? '

 

    • Specifies the separators used in the message.
    • + is the component data element separator.
    • . is the decimal mark.
    • ? is the release character.
    • ' is the segment terminator.
  1. UNB Segment:

UNB+UNOC:3+SENDERID+RECEIVERID+210101:1200+123456'

    • UNOC:3 specifies the syntax identifier and version number.
    • SENDERID and RECEIVERID are the identifiers for the sender and receiver.
    • 210101:1200 is the date and time of the interchange (YYMMDD).
    • 123456 is the interchange control reference.
  1. UNH Segment:

UNH+1+ORDERS:D:96A:UN:EAN008'

    • 1 is the message reference number.
    • ORDERS:D:96A:UN:EAN008 specifies the message type (ORDERS), version (D), release (96A), controlling agency (UN), and association assigned code (EAN008).
  1. BGM Segment:

BGM+220+BKOD99+9'

    • 220 is the document/message name code.
    • BKOD99 is the document/message number.
    • 9 is the message function code.
  1. DTM Segment:

DTM+137:20020910:102'

    • 137 is the date/time/period qualifier.
    • 20020910 is the date.
    • 102 is the date format qualifier.
  1. NAD Segment:

NAD+BY+5412345000176::9'

    • BY is the party qualifier (buyer).
    • 5412345000176 is the party identification.
    • 9 is the code list qualifier.
  1. LIN Segment:

LIN+1++1234567890123:SRV'

    • 1 is the line item number.
    • 1234567890123 is the item number.
    • SRV is the item number type.
  1. QTY Segment:

QTY+47:1020:EA'

    • 47 is the quantity qualifier.
    • 1020 is the quantity.
    • EA is the measure unit qualifier.
  1. UNT Segment:

UNT+7+1'

    • 7 is the number of segments in the message.
    • 1 is the message reference number.
  1. UNZ Segment:

UNZ+1+123456'

    • 1 is the number of messages in the interchange.
    • 123456 is the interchange control reference.

Parsing EDIFACT Messages

To parse EDIFACT messages programmatically, you typically follow these steps:

  1. Read the EDIFACT file: Load the EDIFACT message into your program.
  2. Split the message into segments: Use the segment terminator (') to split the message.
  3. Split segments into data elements: Use the data element separator (+) to split each segment.
  4. Split data elements into component elements: Use the component data element separator (:) to split complex data elements.
  5. Map segments to data structures: Map the parsed segments to your data structures for further processing.

Example Code to Parse EDIFACT in Java

Here's an example of how you might start parsing an EDIFACT message in Java:

java

package com.kartik;



import java.io.FileOutputStream;

import java.io.OutputStream;



import javax.xml.transform.stream.StreamResult;

import javax.xml.transform.stream.StreamSource;



import com.ddtek.xmlconverter.ConvertFromXML;

import com.ddtek.xmlconverter.ConvertToXML;

import com.ddtek.xmlconverter.ConverterFactory;



public class XmlToEdi {

public static void main(String[] args) throws Throwable {

ConverterFactory cf = new ConverterFactory();

OutputStream os = null;

try {

 ConvertToXML c2x = cf.newConvertToXML("EDI");

 os = new FileOutputStream("d:\\SCC\\flight_edi.xml");

 c2x.convert(new StreamSource("d:\\SCC\\flight_edi.edi"), new StreamResult(os));

 os.close();

 System.out.println(" Converted ");

} catch (Exception e) {

 

}



try {

 ConvertFromXML c2x = cf.newConvertFromXML("EDI");

 os = new FileOutputStream("d:\\SCC\\flight_edi_new.edi");

 c2x.convert(new StreamSource("d:\\SCC\\flight_edi_edi.xml"), new StreamResult(os));

 os.close();

 System.out.println(" Converted ");

} catch (Exception e) {

 

}

}

}

 

 

Input File: flight_edi.edi

UNA:+.? '

UNB+UNOB:4+STYLUSSTUDIO:1+DATADIRECT:1+20051107:1159+6002'

UNH+SSDD1+ORDERS:D:03B:UN:EAN008'

BGM+220+BKOD99+9'

DTM+137:20051107:102'

NAD+BY+5412345000176::9'

NAD+SU+4012345000094::9'

LIN+1+1+0764569104:IB'

QTY+1:25'

FTX+AFM+1++XPath 2.0 Programmer?'s Reference'

LIN+2+1+0764569090:IB'

QTY+1:25'

FTX+AFM+1++XSLT 2.0 Programmer?'s Reference'

LIN+3+1+1861004656:IB'

QTY+1:16'

FTX+AFM+1++Java Server Programming'

LIN+4+1+0596006756:IB'

QTY+1:10'

FTX+AFM+1++Enterprise Service Bus'

UNS+S'

CNT+2:4'

UNT+22+SSDD1'

UNZ+1+6002'

 

 

Output File: flight_edi.xml

<?xml version="1.0" encoding="UTF-8"?>

<EDIFACT>

 <UNB>

  <UNB01>

   <UNB0101><!--0001: Syntax identifier-->UNOB<!--UN/ECE level B--></UNB0101>

   <UNB0102><!--0002: Syntax version number-->4<!--Version 4--></UNB0102>

  </UNB01>

  <UNB02>

   <UNB0201><!--0004: Interchange sender identification-->STYLUSSTUDIO</UNB0201>

   <UNB0202><!--0007: Identification code qualifier-->1<!--DUNS (Data Universal Numbering System)--></UNB0202>

  </UNB02>

  <UNB03>

   <UNB0301><!--0010: Interchange recipient identification-->DATADIRECT</UNB0301>

   <UNB0302><!--0007: Identification code qualifier-->1<!--DUNS (Data Universal Numbering System)--></UNB0302>

  </UNB03>

  <UNB04>

   <UNB0401><!--0017: Date-->20051107</UNB0401>

   <UNB0402><!--0019: Time-->1159</UNB0402>

  </UNB04>

  <UNB05><!--0020: Interchange control reference-->6002</UNB05>

 </UNB>

 <ORDERS>

  <UNH>

   <UNH01><!--0062: Message reference number-->SSDD1</UNH01>

   <UNH02>

    <UNH0201><!--0065: Message type-->ORDERS<!--Purchase order message--></UNH0201>

    <UNH0202><!--0052: Message version number-->D<!--Draft version/UN/EDIFACT Directory--></UNH0202>

    <UNH0203><!--0054: Message release number-->03B<!--Release 2003 - B--></UNH0203>

    <UNH0204><!--0051: Controlling agency, coded-->UN<!--UN/CEFACT--></UNH0204>

    <UNH0205><!--0057: Association assigned code-->EAN008</UNH0205>

   </UNH02>

  </UNH>

  <BGM>

   <BGM01>

    <BGM0101><!--1001: Document name code-->220<!--Order--></BGM0101>

   </BGM01>

   <BGM02>

    <BGM0201><!--1004: Document identifier-->BKOD99</BGM0201>

   </BGM02>

   <BGM03><!--1225: Message function code-->9<!--Original--></BGM03>

  </BGM>

  <DTM>

   <DTM01>

    <DTM0101><!--2005: Date or time or period function code qualifier-->137<!--Document/message date/time--></DTM0101>

    <DTM0102><!--2380: Date or time or period text-->20051107</DTM0102>

    <DTM0103><!--2379: Date or time or period format code-->102<!--CCYYMMDD--></DTM0103>

   </DTM01>

  </DTM>

  <GROUP_2>

   <NAD>

    <NAD01><!--3035: Party function code qualifier-->BY<!--Buyer--></NAD01>

    <NAD02>

     <NAD0201><!--3039: Party identifier-->5412345000176</NAD0201>

     <NAD0203><!--3055: Code list responsible agency code-->9<!--EAN International--></NAD0203>

    </NAD02>

   </NAD>

  </GROUP_2>

  <GROUP_2>

   <NAD>

    <NAD01><!--3035: Party function code qualifier-->SU<!--Supplier--></NAD01>

    <NAD02>

     <NAD0201><!--3039: Party identifier-->4012345000094</NAD0201>

     <NAD0203><!--3055: Code list responsible agency code-->9<!--EAN International--></NAD0203>

    </NAD02>

   </NAD>

  </GROUP_2>

  <GROUP_28>

   <LIN>

    <LIN01><!--1082: LINE ITEM IDENTIFIER-->1</LIN01>

    <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>

    <LIN03>

     <LIN0301><!--7140: Item identifier-->0764569104</LIN0301>

     <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>

    </LIN03>

   </LIN>

   <QTY>

    <QTY01>

     <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>

     <QTY0102><!--6060: Quantity-->25</QTY0102>

    </QTY01>

   </QTY>

   <FTX>

    <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>

    <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>

    <FTX04>

     <FTX0401><!--4440: Free text-->XPath 2.0 Programmer's Reference</FTX0401>

    </FTX04>

   </FTX>

  </GROUP_28>

  <GROUP_28>

   <LIN>

    <LIN01><!--1082: LINE ITEM IDENTIFIER-->2</LIN01>

    <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>

    <LIN03>

     <LIN0301><!--7140: Item identifier-->0764569090</LIN0301>

     <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>

    </LIN03>

   </LIN>

   <QTY>

    <QTY01>

     <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>

     <QTY0102><!--6060: Quantity-->25</QTY0102>

    </QTY01>

   </QTY>

   <FTX>

    <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>

    <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>

    <FTX04>

     <FTX0401><!--4440: Free text-->XSLT 2.0 Programmer's Reference</FTX0401>

    </FTX04>

   </FTX>

  </GROUP_28>

  <GROUP_28>

   <LIN>

    <LIN01><!--1082: LINE ITEM IDENTIFIER-->3</LIN01>

    <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>

    <LIN03>

     <LIN0301><!--7140: Item identifier-->1861004656</LIN0301>

     <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>

    </LIN03>

   </LIN>

   <QTY>

    <QTY01>

     <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>

     <QTY0102><!--6060: Quantity-->16</QTY0102>

    </QTY01>

   </QTY>

   <FTX>

    <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>

    <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>

    <FTX04>

     <FTX0401><!--4440: Free text-->Java Server Programming</FTX0401>

    </FTX04>

   </FTX>

  </GROUP_28>

  <GROUP_28>

   <LIN>

    <LIN01><!--1082: LINE ITEM IDENTIFIER-->4</LIN01>

    <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>

    <LIN03>

     <LIN0301><!--7140: Item identifier-->0596006756</LIN0301>

     <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>

    </LIN03>

   </LIN>

   <QTY>

    <QTY01>

     <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>

     <QTY0102><!--6060: Quantity-->10</QTY0102>

    </QTY01>

   </QTY>

   <FTX>

    <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>

    <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>

    <FTX04>

     <FTX0401><!--4440: Free text-->Enterprise Service Bus</FTX0401>

    </FTX04>

   </FTX>

  </GROUP_28>

  <UNS>

   <UNS01><!--0081: Section identification-->S<!--Detail/summary section separation--></UNS01>

  </UNS>

  <CNT>

   <CNT01>

    <CNT0101><!--6069: Control total type code qualifier-->2<!--Number of line items in message--></CNT0101>

    <CNT0102><!--6066: Control total quantity-->4</CNT0102>

   </CNT01>

  </CNT>

  <UNT>

   <UNT01><!--0074: Number of segments in a message-->20</UNT01>

   <UNT02><!--0062: Message reference number-->SSDD1</UNT02>

  </UNT>

 </ORDERS>

 <UNZ>

  <UNZ01><!--0036: Interchange control count-->1</UNZ01>

  <UNZ02><!--0020: Interchange control reference-->6002</UNZ02>

 </UNZ>

</EDIFACT>

 

 

 


How to Convert EDIFACT messages using Stylus Studio

Converting EDIFACT messages using Stylus Studio involves a series of steps, as Stylus Studio is a comprehensive tool for XML, XSLT, and other data integration tasks. Here is a general outline of the process:

  1. Open Stylus Studio:
    • Launch the Stylus Studio application. XMl to Java object and java object to xml creation using JAXB So download
      stylus-studio-enterprise-16-x64.exe 
  2. Create a New Project:
    • Go to File > New > Project.
    • Name your project and save it.
  3. Import the EDIFACT File:
    • In your project, right-click and select Import File.
    • Navigate to your EDIFACT message file and import it.
  4. Convert EDIFACT to XML:
    • Stylus Studio provides built-in support for converting EDIFACT messages to XML.
    • Right-click on the EDIFACT file in your project and select Convert to XML.
    • Stylus Studio will prompt you to choose an EDIFACT message format. Choose the appropriate format that matches your EDIFACT message.
    • The conversion wizard will guide you through the process, and the output will be an XML representation of the EDIFACT message.
  5. Editing the XML:
    • Once converted to XML, you can edit the XML as needed within Stylus Studio using its XML editor.
  6. Convert XML Back to EDIFACT (if needed):
    • If you need to convert the edited XML back to an EDIFACT message, Stylus Studio also supports this.
    • Right-click on the XML file and select Convert to EDIFACT.
    • Follow the wizard to convert the XML back to the EDIFACT format.

Example EDIFACT to XML Conversion

Below is a simplified example of how an EDIFACT message might look and how you could process it:

Example EDIFACT Message:

 

UNH+1+ORDERS:D:96A:UN:EAN008'

BGM+220+BKOD99+9'

DTM+137:20020910:102'

NAD+BY+5412345000176::9'

LIN+1++1234567890123:SRV'

QTY+47:1020:EA'

 

Converted XML (simplified example):

xml

<UNH>

    <MessageRefNumber>1</MessageRefNumber>

    <MessageType>ORDERS</MessageType>

    <Version>D</Version>

    <Release>96A</Release>

    <Agency>UN</Agency>

    <Association>EAN008</Association>

</UNH>

<BGM>

    <DocumentMessageName>220</DocumentMessageName>

    <DocumentMessageNumber>BKOD99</DocumentMessageNumber>

    <MessageFunctionCode>9</MessageFunctionCode>

</BGM>

<DTM>

    <DateTimePeriodQualifier>137</DateTimePeriodQualifier>

    <DateTimePeriod>20020910</DateTimePeriod>

    <DateFormatQualifier>102</DateFormatQualifier>

</DTM>

<NAD>

    <PartyQualifier>BY</PartyQualifier>

    <PartyIdentification>5412345000176</PartyIdentification>

    <CodeListQualifier>9</CodeListQualifier>

</NAD>

<LIN>

    <LineItemNumber>1</LineItemNumber>

    <ActionRequestCode></ActionRequestCode>

    <ItemNumberIdentification>1234567890123</ItemNumberIdentification>

    <ItemNumberType>SRV</ItemNumberType>

</LIN>

<QTY>

    <QuantityQualifier>47</QuantityQualifier>

    <Quantity>1020</Quantity>

    <MeasureUnitQualifier>EA</MeasureUnitQualifier>

</QTY>

 

Notes

  • The conversion to XML helps in making the data readable and easier to manipulate.
  • Ensure that you select the correct EDIFACT format during the conversion process.
  • Stylus Studio’s documentation and support can provide more detailed guidance specific to your needs and EDIFACT message types.

Additional Resources

  • Stylus Studio Documentation: For detailed steps and features.
  • EDIFACT Standards Documentation: To understand the specific segments and elements in your EDIFACT messages.
  • Stylus Studio Support and Community: For assistance and troubleshooting.

 Conclusion

EDIFACT is a structured and standardized format for EDI, used widely in various industries. Understanding its segments and data elements is crucial for correctly interpreting and processing EDIFACT messages. The provided example demonstrates how to parse an EDIFACT message in Java, serving as a starting point for more complex processing and integration tasks.

 


Stylus studio
Stylus studio




Post a Comment

0 Comments