× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I still don't see why it would be any easier to parse the XML vs the EDI data. To map it to your database files you still need to know a lot about the EDI document, and about the database document.

If you want to write a full blown mapper and give a way to describe the EDI document, even better to read the XML schema produced by X12, and I expect EDIFACT, then something to describe the structure of the staging tables for that implementation, and another to describe how to map the various data elements to the staging tables, then you would have something that would make life easier. Of course then you would have an EDI mapping program. I believe you will find that this may be a lot harder than it sounds.

You have to be able to process multiple standards, and have a way to know when you get a file from the EDI network which documents are which, and who they belong to because you will get the entire mailbox at once. So you should be able to process the envelopes to select the correct trading partner, document, and standard during the mapping process. Also for a given trading partner you could get multiple documents, and a mix of documents together within the same envelope, so you have to be able to deal with that as well.

Fortunately you shouldn't have to deal with multiple versions of X12 in the same envelope, or or X12 and EDIFACT in the same envelope.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx

-----rpg400-l-bounces@xxxxxxxxxxxx wrote: -----
To: "RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
From: Henrik Rützou
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
Date: 05/12/2011 12:12PM
Subject: EDI to XML ? former(Translating CSV to Data Structure (or iterating through a data structure))

Hi,

would it be an idear if I wrote a subprocedure under powerEXT Core that is
able to convert EDI (ANSI X.12 and EDIfact) to XML?

It would be based on a XML document that describes the EDI document and then
the EDI file itself. The subprocedure would then do a basic syntax check and
a conversion to XML and the XML file could then be processed by any XML
reader.

ediDesc =

<envelope>
 <interchange>
  <segment id="ISA" type="M" max="1" />
 </interchange>
 <group>
  <segment id="GS" type="O" max="1" />
 </group>
 <message name="invoice">
  <segment id="ST" type="M" max="1" />
  <segment id="B3" type="O" max="1" />
  <segment id="K1" type="O" max="12" />
  <Loop0100 max="200" />
   <segment id="N1" type="O" max="1" name="NameSegment" />
   <segment id="L11" type="O" max="12" />
  </Loop0100>
 </message>
</envelope>


ediData =

ST*210*340001\
N1*CN*CONSIGNEE NAME*25*177835\


rc = ediToXML(ediDataAddr:ediDataSize:'X12':ediDescAddr:ediDescSize);

Result with Description =

<invoice>
 <ST>
  <ST01>210</ST01>
  <ST02>340001</ST02>
 </ST>
 <Loop0100>
  <NameSegment id="N1">
   <N101>CN</N101>
   <N102>CONSIGNEE NAME</N102>
   <N103>25</N103>
   <N104>177835</N104>
  </NameSegment>
 </Loop0100>
</invoice>

Result without Description =

<edi>
 <ST>
  <ST01>210</ST01>
  <ST02>340001</ST02>
 </ST>
 <N1>
  <N101>CN</N101>
  <N102>CONSIGNEE NAME</N102>
  <N103>25</N103>
  <N104>177835</N104>
 </N1>
</edi>

Writing raw EDI as nodes and with node/encode support:

ediNode('':'ST');
ediNode('*':'210');
ediNode('*':'3400001');
ediEndNode('\');

Result:

ST*210*340001\

Coding example - Generate a XML-file:

setContent('*none');
ediDesc = storeNew();
storeFromStmf(ediDesc:'/myEdiDesciption.xml');
ediData = StoreNew();
storeFromStmf(ediData:'/myEdi.x12');
rc = ediToXML(storeAddr(ediData)
   :storeSize(ediData)
   :'X12'
   :storeAddr(ediDesc)
   :storeSize(ediDesc));
if rc <> 0;
 dsply 'EDI conversion error';
endif;
echoToStmf('/myEdi.xml':1208);
storeFree(ediDesc);
storeFree(ediData);


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.