Creating Composite Elements – JS

Index

    Creating Composite Elements

    Composite elements are elements that contain a list of elements.

    Example

    const edi = require(‘rdpcrystal-edi-library’);
     
    let doc = new edi.EDILightWeightDocument();
     
    let interchangeLoop = doc.createLoop(“Interchange header”);
    let isa = interchangeLoop.createSegment(“ISA”;
    isa.addElement(“00”);
    isa.addElement(” “);
    isa.addElement(“00”);
    isa.addElement(” “);
    isa.addElement(“ZZ”);
    isa.addElement(“InterchangeSenderID”);
    isa.addElement(“ZZ”);
    isa.addElement(“InterchangeReceiverID”);
    isa.addElement(“070303”);
    isa.addElement(“1804”);
    isa.addElement(“U”);
    isa.addElement(“00401”);
    isa.addElement(“1”);
    isa.addElement(“1”);
    isa.addElement(“T”);
    isa.addElement(“:”);
     
    //Create a new sample composite element
    let compositeElement = new edi.LightWeightElement();
    compositeElement.addCompositeElement(“test1”);
    compositeElement.addCompositeElement(“test2”);
    isa.elements.add(compositeElement);

    When this segment is generated it will look like the following:

    ISA*00* *00* *ZZ*InterchangeSenderID*ZZ*InterchangeReceiverID*070303*1804*U*00401*1*1*T*:*test1:test2~

    in EDI Lightweight Document – JS
    Did this article answer your question?