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; // LOADS SEF FILE oEdidoc.LoadSchema('ORDERS_D96A.SEF',0); // SET TERMINATORS oEdiDoc.SegmentTerminator := ''''; oEdiDoc.ElementTerminator := '+'; oEdiDoc.CompositeTerminator := ':'; oEdiDoc.ReleaseIndicator := '?'; // CREATES THE UNB SEGMENT oInterchange := oEdiDoc.CreateInterchange('UN','D96A') as IediInterchange; oSegment := oInterchange.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,1] := 'UNOA'; // Syntax identifier oSegment.DataElementValue[1,2] := '1'; // Syntax version number oSegment.DataElementValue[2,1] := 'EDIASD'; // Interchange sender identification oSegment.DataElementValue[2,2] := 'ZZZ'; // Partner identification code qualifier oSegment.DataElementValue[3,1] := 'EDITRCK'; // Recipient identification oSegment.DataElementValue[3,2] := 'ZZZ'; // Partner identification code qualifier oSegment.DataElementValue[4,1] := '030407'; // Date oSegment.DataElementValue[4,2] := '1204'; // Time oSegment.DataElementValue[5,0] := '2451840'; //Interchange control reference // CREATES THE UNH SEGMENT oTransactionset := oInterchange.CreateTransactionSet('ORDERS') as IediTransactionset; oSegment := oTransactionset.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,0] := '00001'; // Message reference number oSegment.DataElementValue[2,1] := 'ORDERS'; // Message type identifier oSegment.DataElementValue[2,2] := 'D'; // Message version number oSegment.DataElementValue[2,3] := '96A'; // Message release number oSegment.DataElementValue[2,4] := 'UN'; // Controlling agency // BGM - BEGINNING OF MESSAGE oSegment := oTransactionset.CreateDataSegment('BGM') as IediDataSegment; oSegment.DataElementValue[1,1] := '1'; // Document/message name, coded oSegment.DataElementValue[1,3] := '9'; // Code list responsible agency, coded oSegment.DataElementValue[2,0] := '03134'; // Document/message number oSegment.DataElementValue[3,0] := '9'; // Message function, coded // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '0'; // Date/time/period oSegment.DataElementValue[1,3] := '805'; // Date/time/period format qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('DTM(2)') as IediDataSegment; oSegment.DataElementValue[1,1] := '137'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304071204'; // Date/time/period oSegment.DataElementValue[1,3] := '203'; // Date/time/period format qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('DTM(3)') as IediDataSegment; oSegment.DataElementValue[1,1] := '1'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304080400200304090400'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // RFF - REFERENCE oSegment := oTransactionset.CreateDataSegment('RFF\RFF') as IediDataSegment; oSegment.DataElementValue[1,1] := 'AHI'; // Reference qualifier oSegment.DataElementValue[1,2] := 'RWE001'; // Reference number // NAD - NAME AND ADDRESS oSegment := oTransactionset.CreateDataSegment('NAD\NAD') as IediDataSegment; oSegment.DataElementValue[1,0] := 'ZSH'; // Party qualifier oSegment.DataElementValue[2,1] := 'TRCKRWE'; // Party identification oSegment.DataElementValue[2,3] := '9'; // Code list responsible agency, coded // NAD - NAME AND ADDRESS oSegment := oTransactionset.CreateDataSegment('NAD(2)\NAD') as IediDataSegment; oSegment.DataElementValue[1,0] := 'ZZZ'; // Party qualifier oSegment.DataElementValue[2,1] := 'TRCK'; // Party identification oSegment.DataElementValue[2,3] := '9'; // Code list responsible agency, coded // TDT - DETAILS OF TRANSPORT oSegment := oTransactionset.CreateDataSegment('TDT\TDT') as IediDataSegment; oSegment.DataElementValue[1,0] := '41G'; // Transport stage qualifier oSegment.DataElementValue[3,1] := '70'; // Mode of transport, coded // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('TDT\LOC\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '7'; // Place/location qualifier oSegment.DataElementValue[2,4] := 'TTFH'; // Place/location // LIN - LINE ITEM oSegment := oTransactionset.CreateDataSegment('LIN\LIN') as IediDataSegment; oSegment.DataElementValue[1,0] := '1'; // Line item number // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '123456'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304080400200304080600'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(2)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(2)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '-123456'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(2)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304080600200304080800'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(3)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(3)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '0'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(3)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304080800200304081000'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(4)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(4)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '52301'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(4)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304081000200304081100'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(5)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(5)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '55324'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(5)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304081100200304081600'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(6)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(6)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '-12056'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(6)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304081600200304081900'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(7)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(7)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '0'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(7)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304081900200304082300'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // LOC - PLACE/LOCATION IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('LIN\LOC(8)\LOC') as IediDataSegment; oSegment.DataElementValue[1,0] := '11'; // Place/location qualifier // QTY - QUANTITY oSegment := oTransactionset.CreateDataSegment('LIN\LOC(8)\QTY') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Quantity qualifier oSegment.DataElementValue[1,2] := '5587'; // Quantity oSegment.DataElementValue[1,3] := 'JM1'; // Measure unit qualifier // DTM - DATE/TIME/PERIOD oSegment := oTransactionset.CreateDataSegment('LIN\LOC(8)\DTM') as IediDataSegment; oSegment.DataElementValue[1,1] := '2'; // Date/time/period qualifier oSegment.DataElementValue[1,2] := '200304082300200304090400'; // Date/time/period oSegment.DataElementValue[1,3] := '719'; // Date/time/period format qualifier // NAD - NAME AND ADDRESS oSegment := oTransactionset.CreateDataSegment('LIN\NAD\NAD') as IediDataSegment; oSegment.DataElementValue[1,0] := 'AA'; // Party qualifier oSegment.DataElementValue[2,1] := 'TRCK'; // Party identification oSegment.DataElementValue[2,3] := '9'; // Code list responsible agency, coded // UNS - SECTION CONTROL oSegment := oTransactionset.CreateDataSegment('UNS') as IediDataSegment; oSegment.DataElementValue[1,0] := 'S'; // Section identification // TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS (SAVES) THE EDIDOC OBJECT INTO A FILE. oEdidoc.Save('ORDERS_D96A.EDI',0); end;