The UNB
segment contains the Interchange control reference as the last element. The documentation says it must be unique (see the UN/EDIFACT Syntax Rules, for example):
___________________________________________________________________
0020 an..14 M INTERCHANGE CONTROL Unique reference
REFERENCE assigned by sender
___________________________________________________________________
The UNB
contains also sender ID, recipient ID, date and time.
Now... In what context the interchange control reference must be unique? It is assigned by sender. So, is it unique for the same sender ID or for combination of the sender and recipient ID?
Say, if the sender uses more systems to send the messages, should that be reflected in the sender ID? Say, if some serious hardware failure happens, should the new hardware use a different sender ID to ensure the uniquenes of the Interchange Control Reference?
The combination of reference number, sender id and receiver id, must be unique. The reference numbers are often sequentially generated for the sender id\receiver id pair.
Many applications internally use a simple table, with sender id\receiver id as the primary key, and a ref number column that gets incremented or set to 0.
The usual reset time is 30 days, after which you can start re-using the same ref numbers, but this varies between applications and trading partners.
Destination systems are sometimes configured to detect duplicates by these three values so that if you send out the same interchange more than once, all subsequent interchanges will be rejected.