Segment Counter

I have to populate the CNT segment of an EDIFACT message with a segment count.

Not all of the segments, simply those that lie between the UNH and UNT segments, including the CNT itself.

I know there is a convertToString function that will count all segments, but I do not think this will give me what I need.


I know I can set up a crude transformer after I create each segment, but it doesn’t seem very elegant.

Any suggestions.


I think CNT in EDIFACT is not total number of segments but a total functionally related to the data like total number of line in Invoice/PO or total weight or number of units etc. which you can always count while making the EDI.

For Despatch Advice you know how many lines in it.

Thank you