If you want to set your own custom value for the “Message Reference Number” (0062) field in an UNT segment, you have to supply your own value for the “Number of Segments in a Message” (0074) field. This could be done in several ways, one way is to use two scripts functiods with inline C#, like this (in this particular example the output is a pseudo edifact file with a custom made schema, but this will work ok for the supplied edifact schemas as well):
The first script functiod should be connected to all segments that should be counted (UNH, BGM, …), see image below.
And contain the following code:
// Global counter
int number = 0;
// Return number of segments in mapped message
public void CalcNumSegments()
{
number++;
}
Connect your second script functiod to the “Number of Segments in a Message” (0074) field and use the following code:
// Return number of segments in mapped message
public int CalcNumSegments(string dummy)
{
// Add 1 for UNT itself
return number +1;
}
The drawback for this method is that if you connect the first functiod to segments that are not mapped in the map, you will get empty nodes (this could be solved by adding logical functiods to any segments that may or may not be mapped).
