BizTalk EDI “Leading or trailing space found”

How to solve this Error

A message sent to adapter "FILE" on send port "sp_856_EDI_Out_FILE" 
with URI "e:\Messages\MyApp\Process\856EDI_Temp\%SourceFileName%" is suspended. 
 Error details: Unable to read the stream produced by the pipeline. 
 Details: Error: 1 (Field level error)
  SegmentID: N4
  Position in TS: 9
  Data Element ID: N401
  Position in Segment: 1
  Data Value: 
  6: Leading or trailing space found  
 MessageId:  {A29AF353-8E1D-49AA-BEDE-D6318C0F3F79}
 InstanceID: {980FBB92-21B7-4B86-AA0C-54CA810AA850}

Solution 1 – Fix the bad data

The N401 refers to the first element of the N4 segment, which is the city of the city, state, address.
In our case, the client sent us this in the EDI 850 message.

N4^CLOVIS    ^CA^93612^US~

They should have trimmed the spaces after the city name of “CLOVIS”. Oddly enough, the error did not occur on the 850, but on the 856. So we stored the data in our database with the trailing blanks. We extract data to an XML file and saved to disk, so I was able to edit the XML and resubmit it. If you can do this or not depends on how you have your set up your send/receive port structure (or your orchestration flow).

Solution 2 – Turn off EDI validation

Validation can be changed as follows:
1) From BizTalk Admin console, expand the “Parties”
2) Find the Profile, then the Agreement for the specific party. Open the agreement.
3) Click on the top tab that indicates message sent to that party.
4) Click on the left option called “Validation” and you will see something like the screen below.

EDI Validation Options
EDI Validation Options

Leave a Reply