var oEdiDoc: IediDocument; oSchema: IediSchema; oSchemas: IediSchemas; oInterchange: IediInterchange; oGroup: IediGroup; oTransactionset: IediTransactionset; oSegment: IediDataSegment; begin // CREATES OEDIDOC OBJECT oEdidoc := coedidocument.Create; // 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. oSchemas := oEdiDoc.GetSchemas as IediSchemas; oSchemas.EnableStandardReference := false; // ENABLES FORWARD WRITE, AND INCREASES BUFFER I/O TO IMPROVE PERFORMANCE oEdiDoc.CursorType := 2; oEdiDoc.Property_[1002] := 200; // SET TERMINATORS oEdiDoc.SegmentTerminator := '~{13:10}'; oEdiDoc.ElementTerminator := '*'; oEdiDoc.CompositeTerminator := '>'; // LOADS SEF FILE oEdidoc.LoadSchema('810_X12-4010.SEF',0); // CREATES THE ISA SEGMENT oInterchange := oEdidoc.CreateInterchange('X','004010') as IediInterchange; oSegment := oInterchange.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,0] := '00'; // Authorization Information Qualifier oSegment.DataElementValue[2,0] := ' '; // Authorization Information oSegment.DataElementValue[3,0] := '00'; // Security Information Qualifier oSegment.DataElementValue[4,0] := ' '; // Security Information oSegment.DataElementValue[5,0] := 'ZZ'; // Interchange ID Qualifier oSegment.DataElementValue[6,0] := 'SENDERISA '; // Interchange Sender ID oSegment.DataElementValue[7,0] := 'ZZ'; // Interchange ID Qualifier oSegment.DataElementValue[8,0] := 'RECEIVERISA '; // Interchange Receiver ID oSegment.DataElementValue[9,0] := '960807'; // Interchange Date oSegment.DataElementValue[10,0] := '1548'; // Interchange Time oSegment.DataElementValue[11,0] := 'U'; // Interchange Control Standards Identifier oSegment.DataElementValue[12,0] := '00401'; // Interchange Control Version Number oSegment.DataElementValue[13,0] := '000000020'; // Interchange Control Number oSegment.DataElementValue[14,0] := '0'; // Acknowledgment Requested oSegment.DataElementValue[15,0] := 'T'; // Usage Indicator oSegment.DataElementValue[16,0] := '>'; // Component Element Separator // CREATES THE GS SEGMENT oGroup := oInterchange.CreateGroup('004010') as IediGroup; oSegment := oGroup.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,0] := 'IN'; // Functional Identifier Code oSegment.DataElementValue[2,0] := 'SENDERDEPT'; // Application Sender's Code oSegment.DataElementValue[3,0] := '007326879'; // Application Receiver's Code oSegment.DataElementValue[4,0] := '19960807'; // Date oSegment.DataElementValue[5,0] := '1548'; // Time oSegment.DataElementValue[6,0] := '1'; // Group Control Number oSegment.DataElementValue[7,0] := 'X'; // Responsible Agency Code oSegment.DataElementValue[8,0] := '004010'; // Version / Release / Industry Identifier Code // CREATES THE ST SEGMENT oTransactionset := oGroup.CreateTransactionset('810') as IediTransactionset; oSegment := oTransactionset.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,0] := '810'; // Transaction Set Identifier Code oSegment.DataElementValue[2,0] := '000000001'; // Transaction Set Control Number // BIG - BEGINNING SEGMENT FOR INVOICE oSegment := oTransactionset.CreateDataSegment('BIG') as IediDataSegment; oSegment.DataElementValue[1,0] := '19971211'; // Date oSegment.DataElementValue[2,0] := '00001'; // Invoice Number oSegment.DataElementValue[4,0] := 'A99999-01'; // Purchase Order Number // N1 - NAME oSegment := oTransactionset.CreateDataSegment('N1\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'ST'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'BUYSNACKS PORT'; // Name oSegment.DataElementValue[3,0] := '9'; // Identification Code Qualifier oSegment.DataElementValue[4,0] := '1223334445'; // Identification Code // N3 - ADDRESS INFORMATION oSegment := oTransactionset.CreateDataSegment('N1\N3') as IediDataSegment; oSegment.DataElementValue[1,0] := '1000 N. SAMPLE HIGHWAY'; // Address Information // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('N1\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'ATHENS'; // City Name oSegment.DataElementValue[2,0] := 'GA'; // State or Province Code oSegment.DataElementValue[3,0] := '30603'; // Postal Code // N1 - NAME oSegment := oTransactionset.CreateDataSegment('N1(2)\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'BT'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'BUYSNACKS'; // Name oSegment.DataElementValue[3,0] := '9'; // Identification Code Qualifier oSegment.DataElementValue[4,0] := '1223334444'; // Identification Code // N3 - ADDRESS INFORMATION oSegment := oTransactionset.CreateDataSegment('N1(2)\N3') as IediDataSegment; oSegment.DataElementValue[1,0] := 'P.O. BOX 0000'; // Address Information // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('N1(2)\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'TEMPLE'; // City Name oSegment.DataElementValue[2,0] := 'TX'; // State or Province Code oSegment.DataElementValue[3,0] := '76503'; // Postal Code // N1 - NAME oSegment := oTransactionset.CreateDataSegment('N1(3)\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'RE'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'FOODSELLER'; // Name oSegment.DataElementValue[3,0] := '9'; // Identification Code Qualifier oSegment.DataElementValue[4,0] := '12345QQQQ'; // Identification Code // N3 - ADDRESS INFORMATION oSegment := oTransactionset.CreateDataSegment('N1(3)\N3') as IediDataSegment; oSegment.DataElementValue[1,0] := 'P.O. BOX 222222'; // Address Information // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('N1(3)\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'DALLAS'; // City Name oSegment.DataElementValue[2,0] := 'TX'; // State or Province Code oSegment.DataElementValue[3,0] := '723224444'; // Postal Code // ITD - TERMS OF SALE/DEFERRED TERMS OF SALE oSegment := oTransactionset.CreateDataSegment('ITD') as IediDataSegment; oSegment.DataElementValue[1,0] := '01'; // Terms Type Code oSegment.DataElementValue[2,0] := '3'; // Terms Basis Date Code oSegment.DataElementValue[3,0] := '1.000'; // Terms Discount Percent oSegment.DataElementValue[5,0] := '15'; // Terms Discount Days Due oSegment.DataElementValue[7,0] := '16'; // Terms Net Days oSegment.DataElementValue[12,0] := '1/15 NET 30'; // Description // FOB - F.O.B. RELATED INSTRUCTIONS oSegment := oTransactionset.CreateDataSegment('FOB') as IediDataSegment; oSegment.DataElementValue[1,0] := 'PP'; // Shipment Method of Payment // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '16'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840022222'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'CRUNCHY CHIPS LSS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(2)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '13'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840033333'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(2)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'NACHO CHIPS LSS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(3)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '32'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840044444'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(3)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'POTATO CHIPS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(4)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '51'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840055555'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(4)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'CORN CHIPS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(5)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '9'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840066666'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(5)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'BBQ CHIPS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(6)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '85'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840077777'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(6)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'GREAT BIG CHIPS LSS'; // Description // IT1 - BASELINE ITEM DATA (INVOICE) oSegment := oTransactionset.CreateDataSegment('IT1(7)\IT1') as IediDataSegment; oSegment.DataElementValue[2,0] := '1'; // Quantity Invoiced oSegment.DataElementValue[3,0] := 'CA'; // Unit or Basis for Measurement Code oSegment.DataElementValue[4,0] := '12.34'; // Unit Price oSegment.DataElementValue[6,0] := 'UA'; // Product/Service ID Qualifier oSegment.DataElementValue[7,0] := '002840088888'; // Product/Service ID // PID - PRODUCT/ITEM DESCRIPTION oSegment := oTransactionset.CreateDataSegment('IT1(7)\PID\PID') as IediDataSegment; oSegment.DataElementValue[1,0] := 'F'; // Item Description Type oSegment.DataElementValue[5,0] := 'MINI CHIPS LSS'; // Description // TDS - TOTAL MONETARY VALUE SUMMARY oSegment := oTransactionset.CreateDataSegment('TDS') as IediDataSegment; oSegment.DataElementValue[1,0] := '255438'; // Amount // CAD - CARRIER DETAIL oSegment := oTransactionset.CreateDataSegment('CAD') as IediDataSegment; oSegment.DataElementValue[5,0] := 'FREEFORM'; // Routing // ISS - INVOICE SHIPMENT SUMMARY oSegment := oTransactionset.CreateDataSegment('ISS\ISS') as IediDataSegment; oSegment.DataElementValue[1,0] := '207'; // Number of Units Shipped oSegment.DataElementValue[2,0] := 'CA'; // Unit or Basis for Measurement Code // CTT - TRANSACTION TOTALS oSegment := oTransactionset.CreateDataSegment('CTT') as IediDataSegment; oSegment.DataElementValue[1,0] := '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',0); end;