Pages

Tuesday, September 30, 2008

Generate Edifact message from a xml

The people of DataDirect made a great product called XML convertors with this you can generate an Edifact message from a xml and back. This is not new but this java software can easily embedded in your own java program. In this blog entry I will show how you can generate an edifact message in a few hours and very flexible.This are the steps to generate an APERAK Edifact message from an Oracle table.Step 1 generate the xsd from xml convertor for our edifact message.In this example I want to generate an Aperak Edifact message so I first need a xml schema,then I know how the xml must look like. You have to do this only once.

You probably noticed I do not have all the required elements in this database xml to generate a complete edifact message. But we will solve this in the next step.With Altova XMLSPY I will generate a new XSD based on this example xml.Now we have two xsd's and a database xml, we can use Altova Mapforce to create a xslt which can transform the database xml to the more complex edifact aperak xml.Step 3 Use Mapforce to create a XSLT.I will use Altova Mapforce because with this program I can visual make a xslt and immediately see the result of the xlst. We need to import the two xsd's in mapforce and make the mappings between these two xsd's and add the missing data to the edifact aperak schema.This is the output of the xslt.

Now we can generate the database xml and have an xlst to transform the xml to the edifact aparak xml. In the last step we can make the edifact message with the xml convertor software.Step 4 Generate the edifact messageWhat really cool is that xml convertor can detect the xml message and transforms it to the right edifact message so you only need this code for all your outgoing edifact messages.

This is the generated edifact messageUNA:+,? 'UNB+UNOC:3+8712423009097:14+8716867999990:14+080928:1347+1001++++++1'UNH+1001+APERAK:D:96A:ZZ:EDINE1'BGM+12E::9+A_200508030000603782+27'DTM+137:200508031112:203'DTM+178:200508031113:203'DTM+735:2:805'RFF+AAN:T200508031110N002'NAD+GRP+8716867999990::9'NAD+GRU+8712423009097::9'ERC+00023::60'FTX+AAO+++ (E)'UNT+11+1001'UNZ+1+1001'

Conclusion, this is an flexible solution to generate an Edifact message. In your java application you can easily embed the xml convertor software and use the xslt to transform the xml. With this solution you can change your backoffice application or edifact message. You only have to change the xslt which is very easy in Altova Mapforce.

7 comments:

Interesting article! I just wanted to also point out that you can convert your DB data directly into EDIFACT in Altova MapForce Enterprise Edition, which has full support for EDI (EDIFACT and X12) and supports a wide variety of DBs, including Oracle. You can also generate Java (or C#, C++) code and embed it in your applications.

I know mapforce ( great product ) but with mapforce you have connection to the Oracle database ( it is not loosely coupled, we use an ESB to deviler the xml's ). The second reason why I like xml convertor, mapforce generates java code for every message, this code has to be included in your own application. xml convertors can detect which conversion it has to do.

Nice Article! You could also use DataDirect's XQuery product in combination with the XML Converters to query your relational database and stream the result directly into EDI (for more info see www.xquery.com). Those who are not familiar with XQuery could use the Stylus Studio mapper to write your XQueries. BTW, Stylus Studio Enterprise has the DataDirect XQuery engine and XML Converters technology integrated!

I bought Stylus Studio Enterprise Edition, because the claim that it comes with EDI converters. But they don't say that you have to pay thousands of dollars to use them on a server. They don't have the price for that on their website, you need to call their sales guys!. Just do your research before buying. I am going to take a look at Altova.

ex Oracle ACE , Java Developer of the year 2009. Co-writer of the OSB Development Cookbook.I am working as a Software Architect and specialized in CI,CD, integration, middleware, security and web development.