Announcement

Collapse
No announcement yet.

Parsing Bits

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    It's not a trick question, more of an open-ended joke really. EDI is an old method of passing business documents between companies. Here's an example format of an EDI document:

    Code:
    ISA*00* *00* *ZZ*PARTNER *16*102096559PROD *060521*0300*U*00400*638504569*0*P*> 
    GS*PO*PARTNER*102096559PROD*20090421*0300*4569*X*004010 
    ST*850*891325 
    BEG*00*NE*MH80312**20090421 
    CUR*SE*USD 
    REF*CT*123456 
    DTM*010*20090421 
    N1*BY*SOLD TO Org Name*ZZ*038181483 
    N1*PO*PAYOR Org Name*ZZ*038181483 
    N1*BT*BILL TO Org Name*ZZ*04332571 
    N1*ST*SHIP TO Org Name*ZZ*0381814830030 
    N2*Partner Name 
    N3*100 Bramshott Rd. 
    N4*San Jose*CA*95110 
    PER*IC*John Doe*TE*8015551234*FX*8015554321*EM*[email protected] 
    PO1*1*11*EA*1499.95*CA*BP*12345678*MG*12070205 
    DTM*010*20090421 
    CTT*1 
    AMT*TT*12 
    SE*18*891325 
    GE*1*4569 
    IEA*1*638504569
    The bitch with these are not all lines and segments are required. Some lines are optional and may not always appear in the document. Othertimes, only specific segments within a line are required. And some companies use different portions of the full EDI spec.

    I wrote a parser via PHP to read the segments I needed, but it wasn't very extendable towards other companies. In the end I've given up and decided to use an open source EDI parser called BOTS written in Python hah

    Comment


    • #17
      PER*IC*John Doe*TE*8015551234*FX*8015554321*EM*[email protected]
      Code:
      <person>
      	<name>John Doe</name>
      	<phone>8015551234</telephone>
      	<fax>8015554321</fax>
      	<email>[email protected]</email>
      </person>
      or

      Code:
      <person name="John Doe" phone="8015551234" fax="8015554321" email="[email protected]" />
      ?
      http://www.nextgenquake.com

      Comment


      • #18
        actually, can you show me what that document would look like if it was properly parsed in it's entirety into XML? If you can, I will fully understand all the EDI delimiters and I can parse it. I wont do it in php though. I will do it in Actionscript. However, these languages are so similar that it could easily be ported to php, even by someone that does not know AS3.
        Last edited by MadGypsy; 04-22-2013, 02:15 PM.
        http://www.nextgenquake.com

        Comment


        • #19
          Oh, I am also assuming that all the capitalized stuff are your standards*. Do you have a list of these?

          *(ex) TE is what everyone uses all the time to indicate a telephone number
          http://www.nextgenquake.com

          Comment


          • #20
            I suppose you could make a map, using the root characters of each line as a key, which return sublevel maps... How did BOTS end up coding it?

            Comment

            Working...
            X