Article: Adding Data Elements

Index

Adding Data Elements

Creating data elements and adding them to a DataSegment is simple.

Example

// Instantiate an instance of EDIDocument and set the name of the file to be created
EDIDocument sampleEDIFile = new EDIDocument(“C:\My837EDIFile.txt”);

// Create an interchange loop. This loop will contain all other loops in the EDI structure
Loop interchangeHeaderLoop = new Loop(“Interchange Header”);

// Create a Data Segment
DataSegment gs = interchangeHeaderLoop.CreateSegment(“GS”);
 
//Set its elements and their values
gs.Elements.Add(“HC”,“ApplicationSenderCode”,“ApplicationReceiverCode”,“2005”,“132334”,“1”,“X”,“004010X098A1”);
 
// Set its elements individually
gs.Elements.Add(“HC”);
gs.Elements.Add(“ApplicationSenderCode”);
gs.Elements.Add(“ApplicationReceiverCode”);
gs.Elements.Add(“2005”);
gs.Elements.Add(“132334”);
gs.Elements.Add(“1”);
gs.Elements.Add(“X”);
gs.Elements.Add(“004010X098A1”);

Related Articles

Main Categories