0

i have 835 EDI file,

ISA*00*          *00*          *33*83876          *ZZ*B00482000   *190128*1100*^*00501*000000001*0*T*:~
ST*835*000000001~
BPR*H*0*C*NON************20190128~
TRN*1*PK673981180*141138499245*PS0087726~
REF*EV*B048499999800~
REF*F2*1083~
DTM*405*20190128~

how shall i extract ST value i.e. 000000001 and so on,

i tried to convert my edi file into XML format using SMOOKS first and then retrieving the data via parent and child node.

  public static void main(String[] args) throws SmooksException, Exception {
    String modelURI = "urn:org.milyn.edi.unedifact:d99a-mapping:1.4";
    UNEdifactInterchangeParser parser = new UNEdifactInterchangeParser();
 //   parser.addMappingModels(modelURI, new URI("/"));
    parser.setFeature(EDIParser.FEATURE_IGNORE_NEWLINES, true);
    SAXHandler handler = new SAXHandler();
    parser.setContentHandler(handler);
    parser.parse(new InputSource(new java.io.FileInputStream(
            "myEDIfile.edi")));
    Document doc = handler.getDocument();
    // Here you have your document
    new XMLOutputter(Format.getPrettyFormat()).output(doc, System.out);
}

but i'm getting error

Caused by: org.xml.sax.SAXException: Unknown/Unexpected UN/EDIFACT control block segment code 'ISA'.

if anyone can help me with the possible solution it would be great. Thanks in advance..

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Nitish Kumar
  • 161
  • 1
  • 4
  • 16

3 Answers3

2

You are trying to parse an X12 835 by using EDIFACT parser.

Instead of UNEdifactInterchangeParser you need to use the corresponding X12 parser.

  • i did try with the x12 parser but the X12Simple class is not present in the API X12-Parser, if you can help me little with the API part that would be great – Nitish Kumar Feb 08 '19 at 14:44
0

Take a look at the X12 parser - it is commonly used for such files:

Documentation: https://media.readthedocs.org/pdf/x12-parser/latest/x12-parser.pdf

GitHub Repo: https://github.com/imsweb/x12-parser

vs97
  • 5,765
  • 3
  • 28
  • 41
0

Take a look at edi-835-parser. It is a Python Library I wrote specifically for parsing the EDI 835 file type and would be more 'out-of-the-box' than using x12-parser.

GitHub Repo: https://github.com/keironstoddart/edi-835-parser.

Keiron Stoddart
  • 328
  • 3
  • 12