Index
Creating A Typed Document
Typed Documents are simple to create and follow the same name and terminology as the implementation guides.
The entire document could be created in one loop as opposed to mirroring the loop structures for a specific implementation guide.
Example
Typed5010Document sampleEDIFile = new Typed5010Document(); //Or Typed4010Document
// Puts the correct number of segments/headers/transaction in X12 SE, GE, and IEA segments
sampleEDIFile.AutoPlaceCorrectNumOfSegments = true;
sampleEDIFile.AutoPlaceNumOfTransactions = true;
sampleEDIFile.AutoPlaceNumOfFunctionalGroups = true;
sampleEDIFile.PadISAElementValues = true;
// Create an interchance loop. This loop will contain all other loops in the EDI structure
DocumentLoop interchangeHeader = sampleEDIFile.MainSection.CreateLoop(“Interchange Header”);
// Create an ISA segment in the interchange loop
ISA isa = interchangeHeader.CreateSegment<ISA>();
isa.AuthorizationInformationQualifier = “00”;
isa.AuthorizationInformation = “”;
isa.SecurityInformationQualifier = “00”;
isa.SecurityInformation = “”;
isa.InterchangeIDQualifier1 = “ZZ”;
isa.InterchangeSenderID = “InterchangeSenderID”;
isa.InterchangeIDQualifier2 = “ZZ”;
isa.InterchangeReceiverID = “InterchangeReceiverID”;
isa.InterchangeDate = “150303”;
isa.InterchangeTime = “1804”;
isa.RepetitionSeparator = “^”;
isa.InterchangeControlVersionNumber = “00501”;
isa.InterchangeControlNumber = “1”;
isa.AcknowledgmentRequested = “1”;
isa.InterchangeUsageIndicator = “P”;
isa.ComponentElementSeparator = “:”;
// Now create the function header section
DocumentLoop functionalHeader = interchangeHeader.CreateLoop(“Functional Header”);
GS gs = functionalHeader.CreateSegment<GS>();
gs.FunctionalIdentifierCode = “HC”;
gs.ApplicationSenderCode = “ApplicationSenderCode”;
gs.ApplicationReceiverCode = “ApplicationReceiverCode”;
gs.Date = “20150303”;
gs.Time = “1424”;
gs.GroupControlNumber = “1234”;
gs.ResponsibleAgencyCode = “X”;
gs.VersionReleaseIndustryIdentifierCode = “005010X222”;
// Create a transaction header loop
DocumentLoop transactionHeader = functionalHeader.CreateLoop(“Transaction Header”);
ST st = transactionHeader.CreateSegment<ST>();
st.TransactionSetIdentifierCode = “837”;
st.TransactionSetControlNumber = “1”;
st.ImplementationConventionReference = “005010X222”;
// Add an BHT segment to the transaction header loop
BHT bht = transactionHeader.CreateSegment<BHT>();
bht.HierarchicalStructureCode = “0019”;
bht.TransactionSetPurposeCode = “00”;
bht.ReferenceIdentification = “44445”;
bht.Date = “20040213”;
bht.Time = “0345”;
// Create the end of the transaction (SE segment). This must be done in a loop.
DocumentLoop endOfTransactionLoop = transactionHeader.CreateLoop(“End Of Transaction”);
SE se = endOfTransactionLoop.CreateSegment<SE>();
se.TransactionSetControlNumber = “1”;
se.NumberOfIncludedSegments = “3”;
// Create the end of the functional group (GE segment). This must be done in a loop.
DocumentLoop endOfFunctionalGroupLoop = functionalHeader.CreateLoop(“End Functional Group”);
GE ge = endOfFunctionalGroupLoop.CreateSegment<GE>();
ge.GroupControlNumber = “11234”;
ge.NumberOfTransactionSetsIncluded = “1”;
// Finally create the end of the interchange loop (IEA segment). This must be done in a loop.
DocumentLoop endInterchangeSection = interchangeHeader.CreateLoop(“End Interchange”);
IEA iea = endInterchangeSection.CreateSegment<IEA>();
iea.InterchangeControlNumber = “123”;
iea.NumberOfIncludedFunctionalGroups = “1”;
// Generate the EDI file
string ediData = sampleEDIFile.ToEDIString(newDelimiters());
// There is also a GenerateEDIFile() method to write directly to a file