Adding Composite Elements

Index

    Adding Composite Elements

    Composite data elements are data elements that can contain other data elements.  A DataSegment contains DataElements. DataElements contains data values and well as other DataElements. A DataElement that contains other DataElements is a composite data element.  Creating a composite data element is very simple.

    Creating a regular element and adding it to a segment

    Example

    // Create a new Data Segment that will hold the data element
    DataSegment segSegment = new DataSegment(“SEG”);
    segSegment.Elements.Add(“A Value”);
     
    or
     
    DataElement regularElement = new DataElement(“A Value”);
    segSegment.Elements.Add(regularElement);

    Creating a composite element and adding it to a segment

    Example

    DataSegment segSegment = new DataSegment(“SEG”);
     
    // Create a Data Element and set its composite property to true
    DataElement compositeElement = new DataElement();
    compositeElement.Composite = true;
     
    // Add elements to the composite element
    compositeElement.Elements.Add(“Composite Value 1”);
    compositeElement.Elements.Add(“Composite Value 2”);
    compositeElement.Elements.Add(“Composite Value 3”);
    compositeElement.Elements.Add(“Composite Value 4”);
    compositeElement.Elements.Add(“Composite Value 5”);
    compositeElement.Elements.Add(“Composite Value 6”);
    compositeElement.Elements.Add(“Composite Value 7”);
    segSegment.Elements.Add(compositeElement);
    in EDI Document
    Did this article answer your question?