'This program is just an example to show how to generate an EDI X12 Student Educational Record (Transcript)
'in VB6 with the Framwork EDI component

Option Explicit

Private Sub Command1_Click()
    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
    Dim nHcLoop As Integer
    Dim nSesLoop As Integer
    Dim nCrsLoop As Integer
    Dim nDegLoop As Integer
    Dim nAtvLoop As Integer
    Dim nTstLoop As Integer
    
    sPath = App.Path & "\"
     
    'CREATES EDI DOCUMENT OBJECT
    Set oEdiDoc = New Fredi.ediDocument
     
    'THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES
    'NOT USE ITS BUILT-IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE.
    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 = "~{13:10}"
    oEdiDoc.ElementTerminator = "*"
    oEdiDoc.CompositeTerminator = "!"
     
    'LOADS THE SEF FILE
    Set oSchema = oEdiDoc.LoadSchema(sPath & "130_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) = "ZZ"     'Interchange ID Qualifier
    oSegment.DataElementValue(6) = "SENDER ID      "     'Interchange Sender ID
    oSegment.DataElementValue(7) = "ZZ"     'Interchange ID Qualifier
    oSegment.DataElementValue(8) = "RECEIVER ID    "     'Interchange Receiver ID
    oSegment.DataElementValue(9) = "010101"     'Interchange Date
    oSegment.DataElementValue(10) = "0101"     'Interchange Time
    oSegment.DataElementValue(11) = "U"     'Interchange Control Standards Identifier
    oSegment.DataElementValue(12) = "00401"     'Interchange Control Version Number
    oSegment.DataElementValue(13) = "000000001"     'Interchange Control Number
    oSegment.DataElementValue(14) = "0"     'Acknowledgment Requested
    oSegment.DataElementValue(15) = "T"     'Usage Indicator
    oSegment.DataElementValue(16) = "!"     'Component Element Separator
     
    'CREATES THE GS SEGMENT
    Set oGroup = oInterchange.CreateGroup("004010")
    Set oSegment = oGroup.GetDataSegmentHeader
    oSegment.DataElementValue(1) = "ED"     'Functional Identifier Code
    oSegment.DataElementValue(2) = "APP SENDER"     'Application Sender's Code
    oSegment.DataElementValue(3) = "APP RECEIVER"     'Application Receiver's Code
    oSegment.DataElementValue(4) = "01010101"     'Date
    oSegment.DataElementValue(5) = "01010101"     'Time
    oSegment.DataElementValue(6) = "1"     '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("130")
    Set oSegment = oTransactionset.GetDataSegmentHeader
    oSegment.DataElementValue(1) = "130"     'Transaction Set Identifier Code
    oSegment.DataElementValue(2) = "0001"     'Transaction Set Control Number
     
    'BGN - BEGINNING SEGMENT
    'create BGN segment
    Set oSegment = oTransactionset.CreateDataSegment("BGN")
    oSegment.DataElementValue(1) = "00"      'Transaction Set Purpose Code
    oSegment.DataElementValue(2) = "1234567"      'Reference Identification
    oSegment.DataElementValue(3) = "20050503"      'Date
    oSegment.DataElementValue(4) = "103020"      'Time
    oSegment.DataElementValue(5) = "ET"      'Time Code
     
    'ERP - EDUCATIONAL RECORD PURPOSE
    'create ERP segment
    Set oSegment = oTransactionset.CreateDataSegment("ERP")
    oSegment.DataElementValue(1) = "PS"      'Transaction Type Code
    oSegment.DataElementValue(2) = "INF"      'Status Reason Code
     
    'REF - REFERENCE IDENTIFICATION
    'create first instance of REF segment
    Set oSegment = oTransactionset.CreateDataSegment("REF")
    oSegment.DataElementValue(1) = "48"      'Reference Identification Qualifier
    oSegment.DataElementValue(2) = "OUAC"      'Reference Identification
     
    'REF - REFERENCE IDENTIFICATION
    'create second of REF segment
    Set oSegment = oTransactionset.CreateDataSegment("REF(2)")
    oSegment.DataElementValue(1) = "LR"      'Reference Identification Qualifier
    oSegment.DataElementValue(2) = "1234567"      'Reference Identification
     
    'DMG - DEMOGRAPHIC INFORMATION
    'create DMG segment
    Set oSegment = oTransactionset.CreateDataSegment("DMG")
    oSegment.DataElementValue(1) = "CC"      'Date Time Period Format Qualifier
    oSegment.DataElementValue(2) = "20050503"      'Date Time Period
    oSegment.DataElementValue(3) = "M"      'Gender Code
    oSegment.DataElementValue(4) = "M"      'Marital Status Code
    oSegment.DataElementValue(5) = "7"      'Race or Ethnicity Code
    oSegment.DataElementValue(6) = "1"      'Citizenship Status Code
     
    'PCL - PREVIOUS COLLEGE
    Set oSegment = oTransactionset.CreateDataSegment("PCL")
    oSegment.DataElementValue(1) = "CS"      'Identification Code Qualifier
    oSegment.DataElementValue(2) = "HB07"      'Identification Code
    oSegment.DataElementValue(7) = "A1B2C3D4E5"      'Description
     
    'N1 - NAME
    'create N1 segment in N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1\N1")
    oSegment.DataElementValue(1) = "AS"      'Entity Identifier Code
    oSegment.DataElementValue(2) = "UNIVERSITY ABC"      'Name
    oSegment.DataElementValue(3) = "CS"      'Identification Code Qualifier
    oSegment.DataElementValue(4) = "112233"      'Identification Code
     
    'N3 - ADDRESS INFORMATION
    'create N3 segment in N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1\N3")
    oSegment.DataElementValue(1) = "1 OPEN AVENUE"      'Address Information
     
    'N4 - GEOGRAPHIC LOCATION
    'create N4 segment in N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1\N4")
    oSegment.DataElementValue(1) = "PARIS"      'City Name
    oSegment.DataElementValue(2) = "CA"      'State or Province Code
    oSegment.DataElementValue(3) = "91506"      'Postal Code
    
    'N1 - NAME
    'create N1 segment in the second instance of the N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N1")    'Having the loop instanace counter (2) in the string syntax is not necessary when cursor type is set to forwardwrite
    oSegment.DataElementValue(1) = "AT"      'Entity Identifier Code
    oSegment.DataElementValue(2) = "COLLEGE RECEIVER"      'Name
     
    'N3 - ADDRESS INFORMATION
    'create N3 segment in the second instance of the N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N3")
    oSegment.DataElementValue(1) = "456 RECEIVER ST"      'Address Information
     
    'N4 - GEOGRAPHIC LOCATION
    'create N4 segment in the second instance of the N1 loop
    Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N4")
    oSegment.DataElementValue(1) = "NEW YORK"      'City Name
    oSegment.DataElementValue(2) = "NY"      'State or Province Code
    oSegment.DataElementValue(3) = "12389"      'Postal Code
    
    'IN1 - INDIVIDUAL IDENTIFICATION
    Set oSegment = oTransactionset.CreateDataSegment("IN1\IN1")
    oSegment.DataElementValue(1) = "1"      'Entity Type Qualifier
    oSegment.DataElementValue(2) = "04"      'Name Type Code
'    oSegment.DataElementValue(3) = "05"      'Entity Identifier Code
'    oSegment.DataElementValue(4) = "AA04"      'Reference Identification Qualifier
'    oSegment.DataElementValue(5) = "93"      'Reference Identification
'    oSegment.DataElementValue(6) = "AA06"      'Individual Relationship Code
'    oSegment.DataElementValue(7) = "AA04"      'Level of Individual, Test, or Course Code
     
    'IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS
    'create first instance of IN2 segment in IN1 loop
    Set oSegment = oTransactionset.CreateDataSegment("IN1\IN2")
    oSegment.DataElementValue(1) = "05"      'Name Component Qualifier
    oSegment.DataElementValue(2) = "SMITH"      'Name
    
    'create second instance of IN2 segment in IN1 loop
    Set oSegment = oTransactionset.CreateDataSegment("IN1\IN2(2)")
    oSegment.DataElementValue(1) = "02"      'Name Component Qualifier
    oSegment.DataElementValue(2) = "MARY"      'Name
    
    'create third instance of IN2 segment in IN1 loop
    Set oSegment = oTransactionset.CreateDataSegment("IN1\IN2(3)")
    oSegment.DataElementValue(1) = "15"      'Name Component Qualifier
    oSegment.DataElementValue(2) = "JONES"      'Name
     
     
    'SST - STUDENT ACADEMIC STATUS
    Set oSegment = oTransactionset.CreateDataSegment("SST\SST")
    oSegment.DataElementValue(1) = "B18"      'Status Reason Code
    oSegment.DataElementValue(2) = "D8"
    oSegment.DataElementValue(3) = "19871215"     'Date Time Period
     
    'N1 - NAME
    Set oSegment = oTransactionset.CreateDataSegment("SST\N1")
    oSegment.DataElementValue(1) = "HS"      'Entity Identifier Code
    oSegment.DataElementValue(2) = "HIGH SCHOOL DCF"      'Name
    oSegment.DataElementValue(3) = "ZZ"      'Identification Code Qualifier
    oSegment.DataElementValue(4) = "A1B2C3D4E5"      'Identification Code
    
    For nAtvLoop = 1 To 2   'number of activities
        Set oSegment = oTransactionset.CreateDataSegment("ATV\ATV")
        oSegment.DataElementValue(3) = "ATHLETE OF THE YEAR 1985"   'Entity Title
        
        Set oSegment = oTransactionset.CreateDataSegment("ATV\DTP")
        oSegment.DataElementValue(1) = "103"    'Award 'Date/Time Qualifier
        oSegment.DataElementValue(2) = "D8"     'Date Time Period Format Qualifier
        oSegment.DataElementValue(3) = "19871130"   'Date Time Period
    Next
     
    For nTstLoop = 1 To 2 'number of tests
        'TST - TEST SCORE RECORD
        Set oSegment = oTransactionset.CreateDataSegment("TST\TST")
        oSegment.DataElementValue(1) = "IDI"      'Educational Test or Requirement Code
        oSegment.DataElementValue(2) = "A1B2C3D4E5"      'Name
        oSegment.DataElementValue(3) = "CC"      'Date Time Period Format Qualifier
        oSegment.DataElementValue(4) = "A1B2C3D4E5"      'Date Time Period
        oSegment.DataElementValue(5) = "A1B2C3D4E5"      'Reference Identification
        oSegment.DataElementValue(6) = "A1B2C3D4E5"      'Reference Identification
        oSegment.DataElementValue(7) = "01"      'Level of Individual, Test, or Course Code
        oSegment.DataElementValue(8) = "01"      'Level of Individual, Test, or Course Code
        oSegment.DataElementValue(9) = "A1B2C3D4E5"      'Date Time Period
        oSegment.DataElementValue(10) = "1"      'Test Norm Type Code
        oSegment.DataElementValue(11) = "1"      'Test Norming Period Code
        oSegment.DataElementValue(13) = "A1B2C3D4E5"      'Date Time Period
        oSegment.DataElementValue(14) = "N"      'Yes/No Condition or Response Code
        oSegment.DataElementValue(15) = "N"      'Yes/No Condition or Response Code
    Next
     
    'LX - ASSIGNED NUMBER
    Set oSegment = oTransactionset.CreateDataSegment("LX\LX")
    oSegment.DataElementValue(1) = "123456"      'Assigned Number
     
    'HS - HEALTH SCREENING
    Set oSegment = oTransactionset.CreateDataSegment("LX\HS")
    oSegment.DataElementValue(1) = "IDIDID"      'Health Screening Type Code
    oSegment.DataElementValue(2) = "CC"      'Date Time Period Format Qualifier
    oSegment.DataElementValue(3) = "A1B2C3D4E5"      'Date Time Period
    oSegment.DataElementValue(4) = "001"      'Status Reason Code
     
    'IMM - IMMUNIZATION STATUS CODE
    Set oSegment = oTransactionset.CreateDataSegment("LX\IMM")
    oSegment.DataElementValue(1) = "IDIDID"      'Immunization Type Code
    oSegment.DataElementValue(2) = "CC"      'Date Time Period Format Qualifier
    oSegment.DataElementValue(3) = "A1B2C3D4E5"      'Date Time Period
    oSegment.DataElementValue(4) = "1"      'Immunization Status Code
    oSegment.DataElementValue(5) = "01"      'Report Type Code
     
    For nHc = 1 To 1 'Number of health condition records
        'HC - HEALTH CONDITION
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\HC")
        oSegment.DataElementValue(1) = "IDIDID"      'Disease Condition Type Code
        oSegment.DataElementValue(3) = "CC"      'Date Time Period Format Qualifier
        oSegment.DataElementValue(4) = "A1B2C3D4E5"      'Date Time Period
        oSegment.DataElementValue(5) = "N"      'Yes/No Condition or Response Code
         
        'N1 - NAME
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\N1")
        oSegment.DataElementValue(1) = "01"      'Entity Identifier Code
        oSegment.DataElementValue(2) = "GROUND TRANSPORT INC"      'Name
        oSegment.DataElementValue(3) = "1"      'Identification Code Qualifier
        oSegment.DataElementValue(4) = "A1B2C3D4E5"      'Identification Code
        oSegment.DataElementValue(5) = "01"      'Entity Relationship Code
        oSegment.DataElementValue(6) = "01"      'Entity Identifier Code
         
        'N2 - ADDITIONAL NAME INFORMATION
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\N2")
        oSegment.DataElementValue(1) = "C/O JANE SMITH"      'Name
        oSegment.DataElementValue(2) = "C/O JANE SMITH"      'Name
         
        'PER - ADMINISTRATIVE COMMUNICATIONS CONTACT
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\PER")
        oSegment.DataElementValue(1) = "1A"      'Contact Function Code
        oSegment.DataElementValue(2) = "A1B2C3D4E5"      'Name
        oSegment.DataElementValue(3) = "AA"      'Communication Number Qualifier
        oSegment.DataElementValue(4) = "A1B2C3D4E5"      'Communication Number
        oSegment.DataElementValue(5) = "AA"      'Communication Number Qualifier
        oSegment.DataElementValue(6) = "A1B2C3D4E5"      'Communication Number
        oSegment.DataElementValue(7) = "AA"      'Communication Number Qualifier
        oSegment.DataElementValue(8) = "A1B2C3D4E5"      'Communication Number
        oSegment.DataElementValue(9) = "A1B2C3D4E5"      'Contact Inquiry Reference
         
        'N3 - ADDRESS INFORMATION
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\N3")
        oSegment.DataElementValue(1) = "1 OPEN AVENUE"      'Address Information
        oSegment.DataElementValue(2) = "1 OPEN AVENUE"      'Address Information
         
        'N4 - GEOGRAPHIC LOCATION
        Set oSegment = oTransactionset.CreateDataSegment("LX\HC\N4")
        oSegment.DataElementValue(1) = "PARIS"      'City Name
        oSegment.DataElementValue(2) = "CA"      'State or Province Code
        oSegment.DataElementValue(3) = "91506"      'Postal Code
        oSegment.DataElementValue(5) = "10"      'Location Qualifier
        oSegment.DataElementValue(6) = "A1B2C3D4E5"      'Location Identifier
    Next
    
    For nSesLoop = 1 To 2 'number of sessions
     
        'SES - ACADEMIC SESSION HEADER
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\SES")
        oSegment.DataElementValue(1) = "2000503"      'Date Time Period
        oSegment.DataElementValue(2) = "1"      'Count
        oSegment.DataElementValue(5) = "SESSION1"      'Name
        oSegment.DataElementValue(14) = "EB3"      'Status Reason Code
         
        'SSE - ENTRY AND EXIT INFORMATION
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\SSE")
        oSegment.DataElementValue(1) = "20051231"      'Date
         
        'NTE - NOTE/SPECIAL INSTRUCTION
        'create first instance of NTE segment in SES loop nested in LX loop
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\NTE")
        oSegment.DataElementValue(2) = "BASIS..."      'Description
         
        'NTE - NOTE/SPECIAL INSTRUCTION
        'create second instance of NTE segment in SES loop nested in LX loop
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\NTE(2)")
        oSegment.DataElementValue(2) = "DECISION..."       'Description
         
        'NTE - NOTE/SPECIAL INSTRUCTION
        'create third instance of NTE segment in SES loop nested in LX loop
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\NTE(3)")
        oSegment.DataElementValue(2) = "ENROLLMENT..."      'Description
         
        'N1 - NAME
        'create N1 segment in SES loop nested in LX loop
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\N1")
        oSegment.DataElementValue(1) = "98"      'Entity Identifier Code
        oSegment.DataElementValue(2) = "DEF INSTITUTION"      'Name
        oSegment.DataElementValue(3) = "CS"      'Identification Code Qualifier
        oSegment.DataElementValue(4) = "LKJGT034T"      'Identification Code
         
        'SUM - ACADEMIC SUMMARY
        Set oSegment = oTransactionset.CreateDataSegment("LX\SES\SUM\SUM")
        oSegment.DataElementValue(1) = "S"      'Academic Credit Type Code
        oSegment.DataElementValue(2) = "U"      'Academic Grade or Course Level Code
        oSegment.DataElementValue(3) = "N"      'Yes/No Condition or Response Code
        oSegment.DataElementValue(5) = "1234567.12"      'Quantity
        oSegment.DataElementValue(6) = "1234567.12"      'Quantity
        oSegment.DataElementValue(9) = "123.12"      'Academic Grade Point Average
        oSegment.DataElementValue(11) = "1234"      'Class Rank
        oSegment.DataElementValue(12) = "1234567.12"      'Quantity
        
        For nCrsLoop = 1 To 2 'number of courses in a session
         
            'CRS - COURSE RECORD
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\CRS\CRS")
            oSegment.DataElementValue(1) = "R"      'Basis for Academic Credit Code
            oSegment.DataElementValue(2) = "S"      'Academic Credit Type Code
            oSegment.DataElementValue(3) = "1234567.12"      'Quantity
            oSegment.DataElementValue(4) = "1234567.12"      'Quantity
            oSegment.DataElementValue(5) = "25"      'Academic Grade Qualifier
            oSegment.DataElementValue(6) = "AB"      'Academic Grade
            oSegment.DataElementValue(13) = "MD"      'Level of Individual, Test, or Course Code
            oSegment.DataElementValue(14) = "BEGIN MATH"      'Name
            oSegment.DataElementValue(15) = "MAT101"      'Reference Identification
            oSegment.DataElementValue(16) = "MATH"      'Name
             
            'NTE - NOTE/SPECIAL INSTRUCTION
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\CRS\NTE")
            oSegment.DataElementValue(2) = "INSTRUCTOR      JOE"      'Description
             
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\CRS\NTE(2)")
            oSegment.DataElementValue(2) = "CLASS AVG       B"      'Description
                  
            'MKS - MARKS AWARDED
            'create MKS segment in MKS loop in first instance of CRS loop nested in SES loop nested in LX loop
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\CRS\MKS\MKS")
            oSegment.DataElementValue(1) = "4"      'Mark Code Type
            oSegment.DataElementValue(2) = "IDI"      'Academic Grade Qualifier
            oSegment.DataElementValue(3) = "AB"      'Academic Grade
        Next    'nCrsLoop
                     
        For nDegLoop = 1 To 1 'number of degrees in a session
         
            'DEG - DEGREE RECORD
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\DEG")
            oSegment.DataElementValue(1) = "2"      'Academic Degree Code
            oSegment.DataElementValue(2) = "D8"      'Date Time Period Format Qualifier
            oSegment.DataElementValue(3) = "20050330"      'Date Time Period
            oSegment.DataElementValue(4) = "BS"      'Description
             
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS")
            oSegment.DataElementValue(1) = "C"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "2005"      'Description
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS(2)")
            oSegment.DataElementValue(1) = "M"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(2) = "CC"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(3) = "US"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "FIELD"      'Academic Field of Study Level or Type Code
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS(3)")
            oSegment.DataElementValue(1) = "M"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(2) = "CC"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(3) = "IS"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "2ND MAJOR"      'Academic Field of Study Level or Type Code
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS(4)")
            oSegment.DataElementValue(1) = "M"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "3RD MAJOR"      'Academic Field of Study Level or Type Code
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS(5)")
            oSegment.DataElementValue(1) = "S"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "1ST OPTION"      'Academic Field of Study Level or Type Code
             
            'FOS - FIELD OF STUDY
            Set oSegment = oTransactionset.CreateDataSegment("LX\SES\DEG\FOS(6)")
            oSegment.DataElementValue(1) = "S"      'Academic Field of Study Level or Type Code
            oSegment.DataElementValue(4) = "2ND OPTION"      'Academic Field of Study Level or Type Code
        Next 'nDegLoop
    Next 'nSesLoop
    
    'TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS (SAVES)
    'THE EDI DOCUMENT OBJECT INTO AN EDI FILE.
    oEdiDoc.Save sPath & "130outbound.x12"
     
    'DESTROYS OBJECTS
    Set oSegment = Nothing
    Set oTransactionset = Nothing
    Set oGroup = Nothing
    Set oSchema = Nothing
    Set oSchemas = Nothing
    Set oInterchange = Nothing
    Set oEdiDoc = Nothing

    MsgBox "Done"
    
End Sub