Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Parsing EDI messages

by Miguel (Friar)
on Oct 09, 2005 at 00:50 UTC ( [id://498480]=perlquestion: print w/replies, xml ) Need Help??

Miguel has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,
I've been looking for information on parsing EDI (Electronic Data Interchange) messages with Perl (in my case, edifact/D93A/INVOIC).

I found, and tried, XML::Edifact module from Michael Koehne. But it doesn't correctly parse my message and I don't need to output the results in XML.

All I need (and I know this is a lot of, and complex, work) is to check if the message is valid, parse it, create a data structure and show some informations to the user.

Googling and searching the monastery didn't help me much on this. So, here I am asking for help from some monk with experience in this field on how and where to start.

Note: I'm aware that this is a task for gurus - which I'm not - and there are lots of commercial and proprietary solutions out there, mainly using Java. But my main interest in this field is to learn, at least the basics, on EDI messages and how Perl can interact with them.

Thank you for your time,
Miguel

Replies are listed 'Best First'.
Re: Parsing EDI messages
by thor (Priest) on Oct 09, 2005 at 14:52 UTC
    There are a couple of key pieces of information (from my point of view anyways):
    • What does your message look like?
    • What does your parsing code look like?
    • In what way do the above two combine to create improper results?
    Your post interests me, actually. We deal with EDIFACT at work, but I didn't know that the format was some sort of standard...

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Thnk you for your interest Thor.
      Altought I don't have all the answers for your questions, here is what I have now:

      My message looks like (I changed some codes):

      UNH+789+INVOIC:D:93A:UN:EAN007' BGM+380+1234567890' DTM+137:20040726:102' RFF+DQ:9087654321' RFF+ON:01234567' NAD+BY+9182736453627::9' RFF+VA:123987465' RFF+API:123' NAD+SU+123987658XXXX::9' RFF+VA:200XXXXXX' NAD+IV+1928374650981::9' CUX+2:EUR:4' LIN+1++230XXXXXXXXXX:EN' IMD+F+M+:::Pencils' QTY+47:70' MOA+66:114.45' PRI+AAB:5.36' PRI+AAA:1.64' ALC+A+++1+TD' PCD+1:69.495' UNS+S' CNT+2:1' MOA+139:138.48' MOA+79:114.45' MOA+125:114.45' MOA+176:24.03' MOA+98:375.20' TAX+7+VAT+++:::21' MOA+176:24.03' UNT+30+798'
      Now, what I want to achieve is:
      1. Validate this message against standard rules (and possibly some set of rules defined by the receiver);
      2. If is valid, create a Perl data structure, something better than this (I'm using a Data segment index from an external file):
      3. Show some informations to the user.

      My problems are:

      1. How to apply the rules (the 'standard' and others defined by the receiver)? There are 100s (perhaps 1000s) of constraints to check. How to do the mappings?
      2. How to construct a solid, fast and accurate data structure that allows me to extract any kind of information from an EDI message?
      Hope this helps.
      Miguel

      Edit: g0n - Added readmore tags

        My problems are:
        1. How to apply the rules (the 'standard' and others defined by the receiver)? There are 100s (perhaps 1000s) of constraints to check. How to do the mappings?
        2. How to construct a solid, fast and accurate data structure that allows me to extract any kind of information from an EDI message?
        I can't speak to the first (showing an example or three of a "rule" might help), but the second almost says database to me. Data structures are geared well towards doing things in a certain way. For instance, if you create a data structure based on people, you could structure it as a hash of hashes, with family name as the primary key and individuals as the sub-keys. Finding how many people are males over 25 from this structure isn't pretty. It seems that you want more flexiblity in the way that you get data out of the parsed message. As it stands, your initial structure didn't look that bad. The only complaint that I'd have against it is the existance of non-descriptive keys at the first level (they're all numbers which don't convey any information to me). After that, everything starts to fall into place.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://498480]
Approved by sk
Front-paged by sgifford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-03-28 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found