When you are sending/creating EDI messages, it is necessary to include a unique message interchange number. This is to ensure each message that we are sending is unique.
In EANCOM/EDIFACT
Element 0020 of UNB segment:
UNB+UNOA:4+xxxxxxx:14+xxxxxx+20160905:0831+00000000000057+ +ORDERS++1'
In X12
Element ISA13 of ISA segment:
ISA*00* *00* *ZZ*167520391 *ZZ*39319445 *991201*1248*U*00200*000000001*0*P*>
This number needs to be persistent. The middleware we are using for EDI transformation should cater to this requirement. I used MS-BizTalk Server for two EDI projects, which cater to 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 MeC_Utilities_db_script.sql).
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.
Steps
- Initialize the message counter for the map.
myMap
is reference to the Map
.
MessageCounter mc = new MessageCounter(myMap);
- Get a new counter value using one of 3 overloads:
String newVal = mc.getNewValue("MsgCounter");
or:
String newVal = mc.getNewValue("MsgCounter",mc.MAP_NAME + mc.PARTNER_ID);
or:
String newVal = mc.getNewValue("MsgCounter",mc.MAP_NAME + mc.PARTNER_ID, null, null, DATE);
If everything is OK, you will return the new counter, otherwise –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.
I’ve started my career in 2001 with Microsoft .net ver 1.0. I’m a MCSD for .net.
Currently, I’m working for Sri Lanka’s largest apparel exporter as a Software Engineer. All projects in .net, MS Sql Server, Biztalk Server, WCF and WPF. And also, I’m developing components to the ERP. In addition to that, I’ve involved to create architecture of ERP integration.