On Tue, May 31, 2022 at 10:21 AM Art Tostaine, Jr. <atostaine@xxxxxxxxx> wrote:
I've done it. I created a data structure for each line type, ST, SE, N1,
N2, etc.
Then I just wrote a parser to look for the segment terminator and put the
data into those fields. I pass the data structure name and the data. I
don't have any code to share though sorry.
It's interesting. Googling around for free Python EDI packages, I
found someone asking on the Python mailing list (20 years ago!)
whether there exists a Python EDI-to-XML converter.
Here are a couple of choice excerpts from the response:
<blockquote>
The main thing is to understand that it's not complicated. I worked on
an EDI product years ago, and we hired several programmers with CS
backgrounds who immediately wanted to use stuff like lex and yacc on
it. Really, EDI was designed to be processed by RPG and COBOL programs
and just doesn't have much syntactic hair. If you find yourself
reaching for fancy compiler implementation techniques, you're probably
misunderstanding something.
</blockquote>
<blockquote>
99% of the work is typing in all the rules from the spec. The code
that follows them should be very simple.
</blockquote>
And Rob said existing EDI packages are expensive.
So it's not surprising to me that plenty of IBM midrange shops,
particularly smaller, more cash-strapped ones, would opt for rolling
their own.
Indeed, data structures in RPG seem almost tailor-made for EDI "parsing".
John Y.