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 'CREATES OEDIDOC 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("810_X12-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) = "SENDERISA " 'Interchange Sender ID oSegment.DataElementValue(7) = "ZZ" 'Interchange ID Qualifier oSegment.DataElementValue(8) = "RECEIVERISA " 'Interchange Receiver ID oSegment.DataElementValue(9) = "960807" 'Interchange Date oSegment.DataElementValue(10) = "1548" 'Interchange Time oSegment.DataElementValue(11) = "U" 'Interchange Control Standards Identifier oSegment.DataElementValue(12) = "00401" 'Interchange Control Version Number oSegment.DataElementValue(13) = "000000020" '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) = "IN" 'Functional Identifier Code oSegment.DataElementValue(2) = "SENDERDEPT" 'Application Sender's Code oSegment.DataElementValue(3) = "007326879" 'Application Receiver's Code oSegment.DataElementValue(4) = "19960807" 'Date oSegment.DataElementValue(5) = "1548" '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("810") Set oSegment = oTransactionset.GetDataSegmentHeader oSegment.DataElementValue(1) = "810" 'Transaction Set Identifier Code oSegment.DataElementValue(2) = "000000001" 'Transaction Set Control Number 'BIG - BEGINNING SEGMENT FOR INVOICE Set oSegment = oTransactionset.CreateDataSegment("BIG") oSegment.DataElementValue(1) = "19971211" 'Date oSegment.DataElementValue(2) = "00001" 'Invoice Number oSegment.DataElementValue(4) = "A99999-01" 'Purchase Order Number 'N1 - NAME Set oSegment = oTransactionset.CreateDataSegment("N1\N1") oSegment.DataElementValue(1) = "ST" 'Entity Identifier Code oSegment.DataElementValue(2) = "BUYSNACKS PORT" 'Name oSegment.DataElementValue(3) = "9" 'Identification Code Qualifier oSegment.DataElementValue(4) = "1223334445" 'Identification Code 'N3 - ADDRESS INFORMATION Set oSegment = oTransactionset.CreateDataSegment("N1\N3") oSegment.DataElementValue(1) = "1000 N. SAMPLE HIGHWAY" 'Address Information 'N4 - GEOGRAPHIC LOCATION Set oSegment = oTransactionset.CreateDataSegment("N1\N4") oSegment.DataElementValue(1) = "ATHENS" 'City Name oSegment.DataElementValue(2) = "GA" 'State or Province Code oSegment.DataElementValue(3) = "30603" 'Postal Code 'N1 - NAME Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N1") oSegment.DataElementValue(1) = "BT" 'Entity Identifier Code oSegment.DataElementValue(2) = "BUYSNACKS" 'Name oSegment.DataElementValue(3) = "9" 'Identification Code Qualifier oSegment.DataElementValue(4) = "1223334444" 'Identification Code 'N3 - ADDRESS INFORMATION Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N3") oSegment.DataElementValue(1) = "P.O. BOX 0000" 'Address Information 'N4 - GEOGRAPHIC LOCATION Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N4") oSegment.DataElementValue(1) = "TEMPLE" 'City Name oSegment.DataElementValue(2) = "TX" 'State or Province Code oSegment.DataElementValue(3) = "76503" 'Postal Code 'N1 - NAME Set oSegment = oTransactionset.CreateDataSegment("N1(3)\N1") oSegment.DataElementValue(1) = "RE" 'Entity Identifier Code oSegment.DataElementValue(2) = "FOODSELLER" 'Name oSegment.DataElementValue(3) = "9" 'Identification Code Qualifier oSegment.DataElementValue(4) = "12345QQQQ" 'Identification Code 'N3 - ADDRESS INFORMATION Set oSegment = oTransactionset.CreateDataSegment("N1(3)\N3") oSegment.DataElementValue(1) = "P.O. BOX 222222" 'Address Information 'N4 - GEOGRAPHIC LOCATION Set oSegment = oTransactionset.CreateDataSegment("N1(3)\N4") oSegment.DataElementValue(1) = "DALLAS" 'City Name oSegment.DataElementValue(2) = "TX" 'State or Province Code oSegment.DataElementValue(3) = "723224444" 'Postal Code 'ITD - TERMS OF SALE/DEFERRED TERMS OF SALE Set oSegment = oTransactionset.CreateDataSegment("ITD") oSegment.DataElementValue(1) = "01" 'Terms Type Code oSegment.DataElementValue(2) = "3" 'Terms Basis Date Code oSegment.DataElementValue(3) = "1.000" 'Terms Discount Percent oSegment.DataElementValue(5) = "15" 'Terms Discount Days Due oSegment.DataElementValue(7) = "16" 'Terms Net Days oSegment.DataElementValue(12) = "1/15 NET 30" 'Description 'FOB - F.O.B. RELATED INSTRUCTIONS Set oSegment = oTransactionset.CreateDataSegment("FOB") oSegment.DataElementValue(1) = "PP" 'Shipment Method of Payment 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1\IT1") oSegment.DataElementValue(2) = "16" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840022222" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "CRUNCHY CHIPS LSS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(2)\IT1") oSegment.DataElementValue(2) = "13" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840033333" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(2)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "NACHO CHIPS LSS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(3)\IT1") oSegment.DataElementValue(2) = "32" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840044444" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(3)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "POTATO CHIPS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(4)\IT1") oSegment.DataElementValue(2) = "51" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840055555" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(4)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "CORN CHIPS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(5)\IT1") oSegment.DataElementValue(2) = "9" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840066666" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(5)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "BBQ CHIPS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(6)\IT1") oSegment.DataElementValue(2) = "85" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840077777" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(6)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "GREAT BIG CHIPS LSS" 'Description 'IT1 - BASELINE ITEM DATA (INVOICE) Set oSegment = oTransactionset.CreateDataSegment("IT1(7)\IT1") oSegment.DataElementValue(2) = "1" 'Quantity Invoiced oSegment.DataElementValue(3) = "CA" 'Unit or Basis for Measurement Code oSegment.DataElementValue(4) = "12.34" 'Unit Price oSegment.DataElementValue(6) = "UA" 'Product/Service ID Qualifier oSegment.DataElementValue(7) = "002840088888" 'Product/Service ID 'PID - PRODUCT/ITEM DESCRIPTION Set oSegment = oTransactionset.CreateDataSegment("IT1(7)\PID\PID") oSegment.DataElementValue(1) = "F" 'Item Description Type oSegment.DataElementValue(5) = "MINI CHIPS LSS" 'Description 'TDS - TOTAL MONETARY VALUE SUMMARY Set oSegment = oTransactionset.CreateDataSegment("TDS") oSegment.DataElementValue(1) = "255438" 'Amount 'CAD - CARRIER DETAIL Set oSegment = oTransactionset.CreateDataSegment("CAD") oSegment.DataElementValue(5) = "FREEFORM" 'Routing 'ISS - INVOICE SHIPMENT SUMMARY Set oSegment = oTransactionset.CreateDataSegment("ISS\ISS") oSegment.DataElementValue(1) = "207" 'Number of Units Shipped oSegment.DataElementValue(2) = "CA" 'Unit or Basis for Measurement Code 'CTT - TRANSACTION TOTALS Set oSegment = oTransactionset.CreateDataSegment("CTT") oSegment.DataElementValue(1) = "7" 'Number of Line Items 'TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS (SAVES) 'THE EDIDOC OBJECT INTO AN EDI FILE. oEdiDoc.Save "810_X12-4010.TXT" 'DESTROYS OBJECTS Set oSegment = Nothing Set oTransactionset = Nothing Set oGroup = Nothing Set oSchema = Nothing Set oSchemas = Nothing Set oInterchange = Nothing Set oEdiDoc = Nothing