Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

EDIFACT - edi - Validator

by tosaiju (Acolyte)
on Aug 11, 2016 at 13:35 UTC ( [id://1169581]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks,

Are there any edi (EDIFACT) data/file validator in Perl.
I can see something like Business::Edifact/Business::Edifact::Interchange - but these modules are only fetching data from edi files and not validating whether its valid as per edi standards.

Many Thanks,

Replies are listed 'Best First'.
Re: EDIFACT - edi - Validator
by GotToBTru (Prior) on Aug 12, 2016 at 03:11 UTC

    I have been watching for EDI-specific modules, and in general, tools like the module you mention are what we find. Tools that work on the segment level. The effort necessary to put together such things on the document level seems to be more than people are willing to do. Having done all that work, you might as well sell it as a translator or syntax-checking tool :). I would think a grammar approach might work, if you have file-based specifications to work from.

    Are you wanting to check syntax of documents you're producing?

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

        EDI is one of the illustrations of the maxim "the nice thing about standards is there are so many to choose from." Well, almost. There are not that many to choose from. The most popular, ANSI X12 and EDIFACT, were developed by multi-industry committees and it shows it. The standards allow so many options that they might as well not be a standard. But it's kept food on my table since 1991.

        Because very frequently trading partners supply each other with written specifications, I have often thought an automated method to read those files (maybe based on a grammar) would help with developing a practical system to validate a particular document for a particular trading partner, without having to put together the full standard for the hundred of document types, each composed of some subset of thousands of segment types, each of which is composed of a subset of thousands of element types. Because even if the standard says, for instance, a G62 segment is required in a 204 document, a particular trading partner can say it isn't required for them, and the same personalization can happen at the element level. Ranting aside, I should actually try this sometime. The potential time savings could be significant.

        You want to hear something funny? Some people think XML would be preferable.

        But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

      Thanks GotToBTru
      yes, I'm looking at something where we can check edi syntax - e.g. MIN/MAX length, dependent/mandatory segments/qualifier and get specific error messages. There are online tools/editors available; but I wanted something to be automated.
      Thanks for the tips - yeah I think a self dictionary should help as well.
        In my limited EDI experience, much like with an XML schema -- I wouldn't trust anything you get to perfectly/fully comply. I like the approach of treating it like an unrestricted DOM and dealing with whatever comes down. People end up sticking weird things into the wrong fields anyway, and business rules will often further restrict things.

        What's your use case?

Re: EDIFACT - edi - Validator
by Laurent_R (Canon) on Aug 11, 2016 at 18:01 UTC
    I have never used that module, but I strongly suspect that the parse function of that module will fail if the format is not valid.
      Thanks Laurent R
      I tried with some simple edi errors and opening/parsing a file - but it didn't throw any error. Also parse is not returning anything (I believe).

        Not returning anything is a failure suggesting that the document is invalid. Unfortunately, it's not telling what or where the problem is.

        Of course, as GotToBTru pointed out, between any 2 trading partners, what is and isn't valid might not match what is agreed upon with another trading partner. (And even when the right technical people are involved in the negotiations, the Golden Rule1 applies.)

        I'd start from known valid documents to verify the EDI parser you are trying to use can actually parse them correctly. If you can't find a parser that works for the documents you need it to process, you may have to write your own.


        1 "He who has the gold makes the rules."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found