MEC: How to Set Message Counter for EDI Message
When you sending/creating EDI messages it is necessary to include unique message interchange number. This is to ensure each message that we are sending is unique.
Element 0020 of UNB segment:
Element ISA13 of ISA segment:
ISA*00* *00* *ZZ*167520391 *ZZ*39319445 *991201*1248*U*00200*000000001*0*P*>
This number need to be persistent. The middleware we are using for EDI transformation should cater this requirement. I used MS-BizTalk Server for two EDI projects, which cater the same. (just by a configuration)
M3 e-Collaborator (MEC) does the same thing in a different way. In the MEC database (e.g. MEC_Storage_TST) has a table (UTIL_Message_Counters) for this purpose.
Table structure is like this:
Note 1: To be able to use this class you must first create this table (use the SQL script
You don’t have to enter a record or write code to save/get data. Instead, you have to write 2 lines of java code in your mapper to get the Value. ( Unique Message Interchange Number)
Note 2: Values in Key fields are case sensitive.
- Initialize the message counter for the map.
myMap is reference to the Map.
- Get a new counter value using one of 3 overloads
If, everything OK, you will return the new counter other wise –1.
If you look at the table (UTIL_Message_Counters) , a record has been added and value will be incremented each time when getNewValue() is called.