As I mentioned in my last post, when we are in the development phase of a BizTalk project, it 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 a 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 : [29] 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.
Sample message:
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'
📝 One-Minute Brief
This post addresses the BizTalk EDI validation error BEC2004: [29] Invalid count specified. This error occurs when the segment count provided in the message trailer (UNT segment) does not match the actual number of segments between the header (UNH) and trailer. Sandro explains how to manually count these segments (including the header and trailer) to ensure the message instance is valid for testing.
Cause
This error is a notification that the number of groups, messages, or segments don’t 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 the UNH segment is 30, and the message has in fact 31 (starting counting from the UNH segment up to the UNT segment).
Solution
You have to change the Number of Segments in the Message element in the UNT segment so that it contains the correct number of groups, messages, or segments, in this case, 31.
Other interesting resources:
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.