DEV Community

Stock Trends with Joe
Stock Trends with Joe

Posted on • Edited on

Parsing X12 850 Purchase Orders in Java with OBOE

No heavy commercial EDI engines required.

If you’ve ever worked with EDI in Java, you know the pain: massive commercial libraries, hundreds of generated classes, or writing your own fragile parser from scratch.

OBOE (Open Business Objects for EDI) changes that.

It’s a mature, lightweight, pure-Java library that uses simple XML message definition files to describe any EDI transaction — including the popular X12 850 Purchase Order.

In this article, I’ll show you exactly how to parse a real X12 850 document in under 30 lines of code using OBOE v2026.04.08 (now available on Maven Central).

Why OBOE?

  • Pure Java (no native dependencies)
  • XML-driven rules → extremely extensible
  • Built-in code generator + GUI editor
  • Supports X12, EDIFACT, TRADACOMS, and HIPAA
  • Battle-tested for over 25 years
  • Zero-cost and now officially on Maven Central

Step 1: Add OBOE to Your Project

<dependency>
    <groupId>io.github.ediandxml</groupId>
    <artifactId>OBOE</artifactId>
    <version>2026.04.08</version>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Step 2: Configure OBOE (oboe.properties)

Create a file named oboe.properties in src/main/resources/:

xmlPath=xml/
searchClassPathForMessageFiles=true
doPrevalidate=true
Enter fullscreen mode Exit fullscreen mode

Step 3: Get An 850 Transaction Set Definition File

If you don't have an 850, copy the 850.xml file in the test/resources/xml folder to your main/resources/xml folder or the resource folder of your
working environment.

Step 4: The Parsing Code

Here’s a complete, working example that parses a real X12 850 Purchase Order:

import java.io.InputStream;
import java.util.Properties;

import io.github.ediandxml.oboe.Containers.Table;
import io.github.ediandxml.oboe.Containers.TransactionSet;
import io.github.ediandxml.oboe.util.Util;
import io.github.ediandxml.oboe.x12.X12DocumentHandler;

public class ParseX12850Example {

    public static void main(String[] args) throws Exception {

        // 1. Load OBOE properties from classpath
        Properties props = new Properties();
        try (InputStream is = ParseX12850Example.class.getClassLoader().getResourceAsStream("oboe.properties")) {
            props.load(is);
        }

        // 2. Create the handler

        X12DocumentHandler handler = new X12DocumentHandler("5-850.x12");

        // 3. Navigate the document
        var envelope = handler.getEnvelope();
        TransactionSet ts = envelope.getFunctionalGroup(0).getTransactionSet(0);
        Table headerTable = ts.getHeaderTable();

        System.out.println("PO Number: " + headerTable.getSegment("BEG").getDataElementValue(3));
        System.out.println("PO Date:   " + headerTable.getSegment("BEG").getDataElementValue(5));
        System.out.println(
                "Buyer:     " + ts.getHeaderTable().getLoop("N1", 1).getSegment("N1", "BY").getDataElementValue(2));

        // Loop through PO1 detail lines

        for (int i = 0; i < ts.getDetailTable().getLoopCnt("PO1"); i++) {
            var po1 = ts.getDetailTable().getLoop("PO1", i).getSegment("PO1");
            System.out.printf("Line %d - Qty: %s, Price: %s, Part: %s%n", i + 1, po1.getDataElementValue(2),
                    po1.getDataElementValue(4), po1.getDataElementValue(6));
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Expected Output

Here is the output from the program run:

What Just Happened?

OBOE used the XML rules file to understand the full structure of the 850, handled envelopes, delimiters, and gave you clean access to every segment and loop.

Try It Yourself

  1. Clone the repo: git clone https://github.com/EDIandXML/OBOE.git
  2. Add the Maven dependency
  3. Drop in the code above
  4. Run it against any 850 file

GitHub Repository

OBOE

Full repo: https://github.com/EDIandXML/OBOE

Maven

Maven Central: io.github.ediandxml:OBOE:2026.04.08

Top comments (0)