'This is just an example program to show how to generate an EDI 204 file using Framework EDI component in VB6
    
    Dim oEdiDoc As Fredi.ediDocument
    Dim oSchema As Fredi.ediSchema
    Dim oSchemas As Fredi.ediSchemas
    Dim oInterchange As Fredi.ediInterchange
    Dim oGroup As Fredi.ediGroup
    Dim oTransactionset As Fredi.ediTransactionSet
    Dim oSegment As Fredi.ediDataSegment
    Dim sPath As String
     
    Command1.Enabled = False
    
    'CREATES EDI DOCUMENT OBJECT
    Set oEdiDoc = New Fredi.ediDocument
     
    'USE THE SEF FILE PROVIDED, AND NOT BUILT-IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE.  IMPROVES PERFORMANCE
    Set oSchemas = oEdiDoc.GetSchemas
    oSchemas.EnableStandardReference = False
     
    'ENABLES FORWARD WRITE, AND INCREASES BUFFER I/O TO IMPROVE PERFORMANCE
    oEdiDoc.CursorType = Cursor_ForwardWrite
    oEdiDoc.Property(Property_DocumentBufferIO) = 200
     
    'SET TERMINATORS
    oEdiDoc.SegmentTerminator = "~"
    oEdiDoc.ElementTerminator = "*"
    oEdiDoc.CompositeTerminator = ">"
     
    'LOADS THE SEF FILE
    Set oSchema = oEdiDoc.LoadSchema(sPath & "204_4010.SEF", 0)
     
    'CREATES THE ISA SEGMENT
    Set oInterchange = oEdiDoc.CreateInterchange("X", "004010")
    Set oSegment = oInterchange.GetDataSegmentHeader
    oSegment.DataElementValue(1) = "00"     'Authorization Information Qualifier
    oSegment.DataElementValue(2) = "          "     'Authorization Information
    oSegment.DataElementValue(3) = "00"     'Security Information Qualifier
    oSegment.DataElementValue(4) = "          "     'Security Information
    oSegment.DataElementValue(5) = "01"     'Interchange ID Qualifier
    oSegment.DataElementValue(6) = "009988777      "     'Interchange Sender ID
    oSegment.DataElementValue(7) = "02"     'Interchange ID Qualifier
    oSegment.DataElementValue(8) = "PRTA           "     'Interchange Receiver ID
    oSegment.DataElementValue(9) = "040309"     'Interchange Date
    oSegment.DataElementValue(10) = "0009"     'Interchange Time
    oSegment.DataElementValue(11) = "U"     'Interchange Control Standards Identifier
    oSegment.DataElementValue(12) = "00401"     'Interchange Control Version Number
    oSegment.DataElementValue(13) = "000018053"     'Interchange Control Number
    oSegment.DataElementValue(14) = "0"     'Acknowledgment Requested
    oSegment.DataElementValue(15) = "P"     'Usage Indicator
    oSegment.DataElementValue(16) = ">"     'Component Element Separator
     
    'CREATES THE GS SEGMENT
    Set oGroup = oInterchange.CreateGroup("004010")
    Set oSegment = oGroup.GetDataSegmentHeader
    oSegment.DataElementValue(1) = "SM"     'Functional Identifier Code
    oSegment.DataElementValue(2) = "009988777"     'Application Sender's Code
    oSegment.DataElementValue(3) = "PRTA"     'Application Receiver's Code
    oSegment.DataElementValue(4) = "20040312"     'Date
    oSegment.DataElementValue(5) = "0009"     'Time
    oSegment.DataElementValue(6) = "2"     'Group Control Number
    oSegment.DataElementValue(7) = "X"     'Responsible Agency Code
    oSegment.DataElementValue(8) = "004010"     'Version / Release / Industry Identifier Code
     
    'CREATES THE ST SEGMENT
    Set oTransactionset = oGroup.CreateTransactionSet("204")
    Set oSegment = oTransactionset.GetDataSegmentHeader
    oSegment.DataElementValue(1) = "204"     'Transaction Set Identifier Code
    oSegment.DataElementValue(2) = "000182983"     'Transaction Set Control Number
     
    'B2 - BEGINNING SEGMENT FOR SHIPMENT INFORMATION TRANSACTION
    Set oSegment = oTransactionset.CreateDataSegment("B2")
    oSegment.DataElementValue(2) = "PRTA"      'Standard Carrier Alpha Code
    oSegment.DataElementValue(4) = "05100"      'Shipment Identification Number
    oSegment.DataElementValue(6) = "PP"      'Shipment Method of Payment
    oSegment.DataElementValue(7) = "B"      'Shipment Qualifier
     
    'B2A - SET PURPOSE
    Set oSegment = oTransactionset.CreateDataSegment("B2A")
    oSegment.DataElementValue(1) = "00"      'Transaction Set Purpose Code
    oSegment.DataElementValue(2) = "MF"      'Application Type
     
    'L11 - BUSINESS INSTRUCTIONS AND REFERENCE NUMBER
    Set oSegment = oTransactionset.CreateDataSegment("L11")
    oSegment.DataElementValue(1) = "999964092847000001"      'Reference Identification
    oSegment.DataElementValue(2) = "CO"      'Reference Identification Qualifier
     
    'L11 - BUSINESS INSTRUCTIONS AND REFERENCE NUMBER
    Set oSegment = oTransactionset.CreateDataSegment("L11(2)")
    oSegment.DataElementValue(1) = "5551007604"      'Reference Identification
    oSegment.DataElementValue(2) = "14"      'Reference Identification Qualifier
     
    'N7 - EQUIPMENT DETAILS
    Set oSegment = oTransactionset.CreateDataSegment("N7\N7")   'CREATES THE N7 SEGMENT IN LOOP N7
    oSegment.DataElementValue(2) = "EQPMNT500"      'Equipment Number
     
    'S5 - STOP OFF DETAILS
    Set oSegment = oTransactionset.CreateDataSegment("S5\S5")   'CREATES THE S5 SEGMENT IN LOOP S5
    oSegment.DataElementValue(1) = "1"      'Stop Sequence Number
    oSegment.DataElementValue(2) = "LD"      'Stop Reason Code
    oSegment.DataElementValue(3) = "49"      'Weight
    oSegment.DataElementValue(4) = "L"      'Weight Unit Code
    oSegment.DataElementValue(5) = "1"      'Number of Units Shipped
    oSegment.DataElementValue(6) = "PC"      'Unit or Basis for Measurement Code
     
    'L11 - BUSINESS INSTRUCTIONS AND REFERENCE NUMBER
    Set oSegment = oTransactionset.CreateDataSegment("S5\L11")  'CREATES THE L11 SEGMENT IN LOOP S5
    oSegment.DataElementValue(1) = "20"      'Reference Identification
    oSegment.DataElementValue(2) = "RU"      'Reference Identification Qualifier
     
    'G62 - DATE/TIME
    Set oSegment = oTransactionset.CreateDataSegment("S5\G62")  'CREATES THE G62 SEGMENT IN LOOP S5
    oSegment.DataElementValue(1) = "78"      'Date Qualifier
    oSegment.DataElementValue(2) = "20040312"      'Date
     
    'N1 - NAME
    Set oSegment = oTransactionset.CreateDataSegment("S5\N1\N1")    'CREATES THE N1 SEGMENT IN LOOP N1 NESTED IN LOOP S5
    oSegment.DataElementValue(1) = "SF"      'Entity Identifier Code
    oSegment.DataElementValue(2) = "Los Angeles XYZ"      'Name
    oSegment.DataElementValue(3) = "93"      'Identification Code Qualifier
    oSegment.DataElementValue(4) = "805"      'Identification Code
     
    'N3 - ADDRESS INFORMATION
    Set oSegment = oTransactionset.CreateDataSegment("S5\N1\N3")    'CREATES THE N3 SEGMENT IN LOOP N1 NESTED IN LOOP S5
    oSegment.DataElementValue(1) = "19499 Downtown Highway"      'Address Information
    oSegment.DataElementValue(2) = "Los Angeles, CA 97230"      'Address Information
     
    'N3 - ADDRESS INFORMATION
    Set oSegment = oTransactionset.CreateDataSegment("S5\N1\N3(2)") 'CREATES THE SECOND INSTANCE OF THE N3 SEGMENT IN LOOP N1 NESTED IN LOOP S5
    oSegment.DataElementValue(1) = "Los Angeles CA,97230"      'Address Information
     
    'N4 - GEOGRAPHIC LOCATION
    Set oSegment = oTransactionset.CreateDataSegment("S5\N1\N4")    'CREATES THE N4 SEGMENT IN LOOP N1 NESTED IN LOOP S5
    oSegment.DataElementValue(1) = "Los Angeles"      'City Name
    oSegment.DataElementValue(2) = "CA"      'State or Province Code
    oSegment.DataElementValue(3) = "97230"      'Postal Code
     
    'G61 - CONTACT
    Set oSegment = oTransactionset.CreateDataSegment("S5\N1\G61")
    oSegment.DataElementValue(1) = "IC"      'Contact Function Code
    oSegment.DataElementValue(2) = "Retail Company A"      'Name
     
    'OID - ORDER IDENTIFICATION DETAIL
    Set oSegment = oTransactionset.CreateDataSegment("S5\OID\OID")
    oSegment.DataElementValue(1) = "334455"      'Reference Identification
    oSegment.DataElementValue(2) = "ABCDEF092847000001"      'Purchase Order Number
    oSegment.DataElementValue(4) = "PC"      'Unit or Basis for Measurement Code
    oSegment.DataElementValue(5) = "1"      'Quantity
    oSegment.DataElementValue(6) = "L"      'Weight Unit Code
    oSegment.DataElementValue(7) = "49"      'Weight
     
    'LAD - LADING DETAIL
    Set oSegment = oTransactionset.CreateDataSegment("S5\OID\LAD")
    oSegment.DataElementValue(1) = "CTN"      'Packaging Form Code
    oSegment.DataElementValue(2) = "1"      'Lading Quantity
    oSegment.DataElementValue(3) = "L"      'Weight Unit Code
    oSegment.DataElementValue(4) = "49"      'Unit Weight
    oSegment.DataElementValue(7) = "UF"      'Product/Service ID Qualifier
    oSegment.DataElementValue(8) = "UDFCI0002078$01"      'Product/Service ID
    oSegment.DataElementValue(13) = "TEST PRODUCT 1 32OZ."      'Lading Description
     
    'S5 - STOP OFF DETAILS
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\S5")    'CREATES THE S5 SEGMENT IN THE SECOND INSTANCE OF LOOP S5
    oSegment.DataElementValue(1) = "2"      'Stop Sequence Number
    oSegment.DataElementValue(2) = "UL"      'Stop Reason Code
    oSegment.DataElementValue(3) = "49"      'Weight
    oSegment.DataElementValue(4) = "L"      'Weight Unit Code
    oSegment.DataElementValue(5) = "1"      'Number of Units Shipped
    oSegment.DataElementValue(6) = "PC"      'Unit or Basis for Measurement Code
     
    'L11 - BUSINESS INSTRUCTIONS AND REFERENCE NUMBER
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\L11")   'CREATES THE L11 SEGMENT IN THE SECOND INSTANCE OF LOOP S5
    oSegment.DataElementValue(1) = "20"      'Reference Identification
    oSegment.DataElementValue(2) = "RU"      'Reference Identification Qualifier
     
    'G62 - DATE/TIME
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\G62")   'CREATES THE G62 SEGMENT IN THE SECOND INSTANCE OF LOOP S5
    oSegment.DataElementValue(1) = "78"      'Date Qualifier
    oSegment.DataElementValue(2) = "20040312"      'Date
     
    'N1 - NAME
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\N1\N1") 'CREATES THE N1 SEGMENT IN LOOP N1 NESTED IN THE SECOND INSTANCE OF LOOP S5
    oSegment.DataElementValue(1) = "CN"      'Entity Identifier Code
    oSegment.DataElementValue(2) = "RESP RELIABLE"      'Name
    oSegment.DataElementValue(3) = "93"      'Identification Code Qualifier
    oSegment.DataElementValue(4) = "3807"      'Identification Code
     
    'N3 - ADDRESS INFORMATION
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\N1\N3") 'CREATES THE N3 SEGMENT IN LOOP N1 NESTED IN THE SECOND INSTANCE OF LOOP S5
    oSegment.DataElementValue(1) = "888 MID WAY"      'Address Information
    oSegment.DataElementValue(2) = "FLOOR B"      'Address Information
     
    'N4 - GEOGRAPHIC LOCATION
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\N1\N4")
    oSegment.DataElementValue(1) = "Los Angeles"      'City Name
    oSegment.DataElementValue(2) = "CA"      'State or Province Code
    oSegment.DataElementValue(3) = "97232"      'Postal Code
     
    'G61 - CONTACT
    Set oSegment = oTransactionset.CreateDataSegment("S5(2)\N1\G61")
    oSegment.DataElementValue(1) = "IC"      'Contact Function Code
    oSegment.DataElementValue(2) = "OVERSEE SUPER"      'Name
    oSegment.DataElementValue(3) = "TE"      'Communication Number Qualifier
    oSegment.DataElementValue(4) = "(555) 555-ABCD"      'Communication Number
     
    'L3 - TOTAL WEIGHT AND CHARGES
    Set oSegment = oTransactionset.CreateDataSegment("L3")
    oSegment.DataElementValue(1) = "49"      'Weight
    oSegment.DataElementValue(2) = "G"      'Weight Qualifier
    oSegment.DataElementValue(11) = "1"      'Lading Quantity
     
    'TRAILING CONTROL SEGMENTS (SE, GE, IEA) ARE AUTOMATICALLY CREATED
    
    'DISPLAY EDI STRING
    MsgBox oEdiDoc.GetEdiString, , "EDI File"
    
    'SAVE EDI OBJECT TO FILE
    oEdiDoc.Save sPath & "204Output.x12"
    
    MsgBox "Done. File saved to " & sPath & "204Output.x12"

     
    'DESTROYS OBJECTS
    Set oSegment = Nothing
    Set oTransactionset = Nothing
    Set oGroup = Nothing
    Set oSchema = Nothing
    Set oSchemas = Nothing
    Set oInterchange = Nothing
    Set oEdiDoc = Nothing

    Click here to download a trial version of the Framework EDI