EDI: Wrapped and Unwrapped

emptywrapper EDI:  Wrapped and UnwrappedEDI in its proper form is wrapped.  This means that there is nothing between the segment terminator and the beginning of the next segment.  Sometimes this is hard to read, for humans anyway.  And at those times people will unwrap the EDI so that it looks more like a flat file.  This is not hard to do, and is useful for debugging and trouble shooting processes.  A good parser or validator should be able to read either file.

Wrapped

As I said wrapped EDI has nothing between the segment terminator and the next segment, in this format;

SEG|||~SEG||||||~

and so on.  Wrapped EDI looks like this:

ISA*00*          *00*          *01*9012345720000  *01*9088877320000  *090508*1459*U*00200*000000001*0*T*:~GS*PO*901234572000*908887732000*090508*1459*1*T*004010~ST*850*0001~BEG*01*BK*99AKDF9DAL393*39483920193843*20090508*AN3920943*AC*IBM*02*AE*02*BA~DTM*002*20090508*1615*CT*CM*DATE TIME PERIOD~N1*AC*ARTHUR JONES*1*9012345918341*11*SE~N2*MAGGIE MCGILLICUTTY*BEVERLY SIMPSON~N3*PO BOX 123*157 WEST 57TH STREET~N4*CINCINNATI*OH*43017*US*IP*02535~PER*AC*ARTHUR JONES*TE*(614)555-1212*TE*(614)555-1212*TE*(614)555-1212*ADDL CONTACT DESC~PO1*AAA849*100*DP*100.00*PD*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY~PID*F*BC*AX*UNSCENTED*GENERAL PURPOSE*BS*SUBQUALIFIER*N*ENG~CTT*10*855*12345678*HB*40*QD*GENERAL PURPOSE~SE*12*0001~GE*1*1~IEA*1*000000001~

Unwrapped

When we unwrap the EDI, we don’t just place any character between the segment terminator and the next segment, we place a carriage return and line feed.  This makes all of the segments appear to be justified like separate lines of a text file.  Thus the format is changed in this manner;

SEG|||~

SEG||||||~

and so on.  Unwrapped EDI looks like this:

ISA*00*          *00*          *01*9012345720000  *01*9088877320000  *090508*1459*U*00200*000000001*0*T*:~
GS*PO*901234572000*908887732000*090508*1459*1*T*004010~
ST*850*0001~
BEG*01*BK*99AKDF9DAL393*39483920193843*20090508*AN3920943*AC*IBM*02*AE*02*BA~
DTM*002*20090508*1615*CT*CM*DATE TIME PERIOD~
N1*AC*ARTHUR JONES*1*9012345918341*11*SE~
N2*MAGGIE MCGILLICUTTY*BEVERLY SIMPSON~
N3*PO BOX 123*157 WEST 57TH STREET~
N4*CINCINNATI*OH*43017*US*IP*02535~
PER*AC*ARTHUR JONES*TE*(614)555-1212*TE*(614)555-1212*TE*(614)555-1212*ADDL CONTACT DESC~
PO1*AAA849*100*DP*100.00*PD*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY*BL*BRAND OR LABEL*ON*CUST12345*AB*ASSEMBLY~
PID*F*BC*AX*UNSCENTED*GENERAL PURPOSE*BS*SUBQUALIFIER*N*ENG~
CTT*10*855*12345678*HB*40*QD*GENERAL PURPOSE~
SE*12*0001~
GE*1*1~
IEA*1*000000001~

Converting from Wrapped to Unwrapped and back

When you need to do this, you need to do this fast, not manually.  Sure the manual way works with small files, but if you are trying to edit a big invoice or order, you will want to do something snappier than walking through the file segment at a time.  Here are two ways to do it with common tools.

VI

To unwrap:

  1. open the file.  Type “vi [file name]“
  2. Hit “:” to get the command prompt
  3. Type “%” to do a every line replace. (may not be needed as this is wrapped, but it doesn’t hurt.)
  4. Type “s” for a substitution.
  5. Type “/” to begin the string to find.  (you may need to escape characters like ~ and | with a .  I will show this in the example)
  6. Type the delimiter to be replaced.
  7. Type “/” to begin the replaced string (again with the possible need to escape characters.)
  8. Type the delimiter again, as we don’t want to lose it, then follow it will a [crtl]+v and [crtl]+m
  9. Type “/” to end the substitution
  10. Type “g” to make it global or indicating all of the instances not just the first one.

It looks like this:  “%s/[delimiter]/[delimiter]^M/g”

Put another way, here is what I typed for our example:  “%s/~/~^M/g”  (notice that I am escaping the ~ with a )

To re-wrap:

  1. open the file.  Type “vi [file name]“
  2. Hit “:” to get the command prompt
  3. Type “%” to do a every line replace. (may not be needed as this is wrapped, but it doesn’t hurt.)
  4. Type “s” for a substitution.
  5. Type “/” to begin the string to find.  (you may need to escape characters like ~ and | with a .  I will show this in the example)
  6. Type “n” to designate the newlines.
  7. Type “/” to begin the replaced string (again with the possible need to escape characters.)
  8. Type “//” to begin and end the substitution.
  9. Type “g” so that it will get any multiples of the newline.

It looks like this: “%s/n//g”

MS Word

To Unwrap:

  1. Open file.
  2. Select Edit>Replace or press [ctrl]+h
  3. In the “Find what” field insert the delimiter.
  4. In the “Replace with” field insert the delimiter, and then click on the “More” button on the bottom of the control.
  5. In more, there is another button called “Special”  Click on this button and select “Manual Line Break”
  6. Click replace all and the EDI will unwrap.

To re-wrap:

  1. Open file.
  2. Select Edit>Replace or press [ctrl]+h
  3. In the “Find what” field click on the “More” button on the bottom of the control.
  4. In more, there is another button called “Special”  Click on this button and select “Manual Line Break”
  5. Don’t put anything in the  “Replace with” field.
  6. Click replace all and the EDI will re-wrap.

Other Tools:

There are lots of other tools that can do the search and replace with newlines, these are only two ways.  If you have one that you would like to share, please let me know.

Looking for something else relating to EDI?  Try here.

Subscribe to "The Integration Engineer" by Email
Find out about the tools and services available at The Integration Engineer's Consulting site.

Related Articles:

Leave a Reply

  • Catagories


  • Affiliate Ads