Generate EDIFACT UNA Last updated: 2021-03-15

EDIFACT UNA

You don't have to explicitly generate UNA segment. EdifactWriter will automatically detect if the separators are different than the default and will write the final message with the correct UNA.

If you want to write UNA explicitly then use the Write() overload which takes UNA as a parameter.

To create a UNA, you can either manually populate it, or use the ToUna() method of the Separators object.

EDIFACT UNA Specification

EDIFACT UNA specification is available at:

ediFabric .NET C# Examples

The example below is part of the ediFabric .NET C# Code Examples.

Download EDI C# Examples

How to generate EDIFACT UNA with ediFabric .NET

 var invoice = EdifactTransactionBuilders.BuildInvoice("1");

 using (var stream = new MemoryStream())
 {
	using (var writer = new EdifactWriter(stream))
	{
		//  Set a custom segment separator
		var separators = new Separators('|',
                          Separators.Edifact.ComponentDataElement,
			  Separators.Edifact.DataElement,
                          Separators.Edifact.RepetitionDataElement,
                          Separators.Edifact.Escape);

                //  Write custom UNA
		writer.Write(separators.ToUna());

		//  Write the UNB with the custom separator set
		writer.Write(SegmentBuilders.BuildUnb("1"), separators);
		writer.Write(invoice);
	}
 }