As I mentioned in my last post, when we are in the development phase of a BizTalk project is normal to validate test instances of messages that are provided with respective schemas before we make final tests, the same happens when we are dealing with EDI (EDIFACT) messages.
When we perform this validation, we can detect if some enumerators in the existing EDI Schema contain all admissible values, or if your partner has some values customized and we have to reflect them in the schema.
Another common problem when we are trying to validate dummy EDI message, provided by our partners, against the schema using Visual Studio is:
” Invoking component…
C:\TestFiles\myEDIsample.txt: error BEC2004: Non Segment level :  Invalid count specified at interchange, group or message level“.
This is a very basic mistake, and usually occurs when dummy messages are delivered to us for testing.
UNA:+,?*' UNB+UNOB:1+UNB2.1+UNB3.1+012301:0123+UNB5' UNH+1000100+ORDERS:D:93A:UN:EAN007' BGM+220+01521710' DTM+137:120530:101' DTM+64:120604:101' DTM+63:120004:101' FTX+AAI+++SOME TEXT' FTX+AAI+++SOME TEXT' FTX+AAI+++SOME TEXT' NAD+BY+8000000001164::9' NAD+DP+8000000009463::9' NAD+IV+8000000013002::9' NAD+SU+8000001459008::9' NAD+PR+8000000016003::9' LIN+1++4001518722937:EN' PIA+1+00:PV+14001518722937:EN' IMD+F+M+:::SOME DESCRIPTION' QTY+21:52' LIN+2++5000014010034:EN' PIA+1+00:PV+15701014010031:EN' IMD+F+M+:::SOME DESCRIPTION' QTY+21:152' LIN+3++5000014016142:EN' PIA+1+00:PV+15701014016149:EN' IMD+F+M+:::SOME DESCRIPTION' QTY+21:304' LIN+4++5006879009752:EN' PIA+1+00:PV+15776879009759:EN' IMD+F+M+:::SOME DESCRIPTION' QTY+21:720' UNS+S' UNT+30+1000100' UNZ+1+UNB5'
This error is a notification that the number of groups, messages, or segments does not match the number given in the UNZ, UNE, UNT, or UST segment; or that the length of an object or the length of encrypted data is not equal to the length stated in the UNO, UNP, USD, or USU segment, i.e., the control count does not match number of instances received.
UNT Segment: UNT is the Message Trailer segment of an EDIFACT document. The UNT segment elements provide information about the number of segments in a message and the reference number for the message. This segment indicates the end of a document.
The following table lists the mandatory elements that the UNT segment contains:
- Number of Segments in the Message: This element contains the total number of segments in the message.
- Message Reference Number: This element contains a unique reference number for the message assigned by the sender. This number must be unique to the functional group, and must match the Message Reference Number in the UNH Segment.
So the problem is that in the sample message the Number of Segments in the Message in UNH segment is 30 and the message has in fact 31 (starting count from the UNH segment up to UNT segment).
You have to change the Number of Segments in the Message element in UNT segment so that contains the correct number of groups, messages, or segments, in this case 31.
Other interesting resources: