procedure TForm1.Button1Click(Sender: TObject); // This is just an example program to show how to generate an EDI X12 130 file // in Delphi with the Framework EDI component var oEdiDoc: IediDocument; oSchema: IediSchema; oSchemas: IediSchemas; oInterchange: IediInterchange; oGroup: IediGroup; oTransactionset: IediTransactionset; oSegment: IediDataSegment; sEdiFile: string; sSefFile: string; sPath: string; begin sSefFile := '130_4010.SEF'; sEdiFile := '130Outbound.x12'; sPath := Trim(GetCurrentDir) + '\'; // CREATES EDI DOCUMENT 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}'; //tilde follwed by CR/LF oEdiDoc.ElementTerminator := '*'; oEdiDoc.CompositeTerminator := '!'; // LOADS SEF FILE oEdidoc.LoadSchema(sPath + sSefFile,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] := 'SENDER ID '; // Interchange Sender ID oSegment.DataElementValue[7,0] := 'ZZ'; // Interchange ID Qualifier oSegment.DataElementValue[8,0] := 'RECEIVER ID '; // Interchange Receiver ID oSegment.DataElementValue[9,0] := '061206'; // Interchange Date oSegment.DataElementValue[10,0] := '0101'; // Interchange Time oSegment.DataElementValue[11,0] := 'U'; // Interchange Control Standards Identifier oSegment.DataElementValue[12,0] := '00401'; // Interchange Control Version Number oSegment.DataElementValue[13,0] := '000000001'; // 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] := 'ED'; // Functional Identifier Code oSegment.DataElementValue[2,0] := 'APP SENDER'; // Application Sender's Code oSegment.DataElementValue[3,0] := 'APP RECEIVER'; // Application Receiver's Code oSegment.DataElementValue[4,0] := '01010101'; // Date oSegment.DataElementValue[5,0] := '01010101'; // 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('130') as IediTransactionset; oSegment := oTransactionset.GetDataSegmentHeader as IediDataSegment; oSegment.DataElementValue[1,0] := '130'; // Transaction Set Identifier Code oSegment.DataElementValue[2,0] := '0001'; // Transaction Set Control Number // BGN - BEGINNING SEGMENT oSegment := oTransactionset.CreateDataSegment('BGN') as IediDataSegment; oSegment.DataElementValue[1,0] := '00'; // Transaction Set Purpose Code oSegment.DataElementValue[2,0] := '1234567'; // Reference Identification oSegment.DataElementValue[3,0] := '20050503'; // Date oSegment.DataElementValue[4,0] := '103020'; // Time oSegment.DataElementValue[5,0] := 'ET'; // Time Code // ERP - EDUCATIONAL RECORD PURPOSE oSegment := oTransactionset.CreateDataSegment('ERP') as IediDataSegment; oSegment.DataElementValue[1,0] := 'PS'; // Transaction Type Code oSegment.DataElementValue[2,0] := 'INF'; // Status Reason Code // REF - REFERENCE IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('REF') as IediDataSegment; oSegment.DataElementValue[1,0] := 'SY'; // Reference Identification Qualifier oSegment.DataElementValue[2,0] := '12345679'; // Reference Identification // N1 - NAME oSegment := oTransactionset.CreateDataSegment('N1\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'AS'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'UNIVERSITY SENDER'; // Name // N3 - ADDRESS INFORMATION oSegment := oTransactionset.CreateDataSegment('N1\N3') as IediDataSegment; oSegment.DataElementValue[1,0] := '123 SENDER AVENUE'; // Address Information // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('N1\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'LOS ANGELES'; // City Name // N1 - NAME oSegment := oTransactionset.CreateDataSegment('N1(2)\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'AT'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'COLLEGE RECEIVER'; // Name // N3 - ADDRESS INFORMATION oSegment := oTransactionset.CreateDataSegment('N1(2)\N3') as IediDataSegment; oSegment.DataElementValue[1,0] := '456 RECEIVER ST'; // Address Information // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('N1(2)\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'NEW YORK'; // City Name // IN1 - INDIVIDUAL IDENTIFICATION oSegment := oTransactionset.CreateDataSegment('IN1\IN1') as IediDataSegment; oSegment.DataElementValue[1,0] := '1'; // Entity Type Qualifier oSegment.DataElementValue[2,0] := '04'; // Name Type Code // IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS oSegment := oTransactionset.CreateDataSegment('IN1\IN2') as IediDataSegment; oSegment.DataElementValue[1,0] := '05'; // Name Component Qualifier oSegment.DataElementValue[2,0] := 'SMITH'; // Name // IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS oSegment := oTransactionset.CreateDataSegment('IN1\IN2(2)') as IediDataSegment; oSegment.DataElementValue[1,0] := '02'; // Name Component Qualifier oSegment.DataElementValue[2,0] := 'MARY'; // Name // IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS oSegment := oTransactionset.CreateDataSegment('IN1\IN2(3)') as IediDataSegment; oSegment.DataElementValue[1,0] := '15'; // Name Component Qualifier oSegment.DataElementValue[2,0] := 'J'; // Name // SST - STUDENT ACADEMIC STATUS oSegment := oTransactionset.CreateDataSegment('SST\SST') as IediDataSegment; oSegment.DataElementValue[1,0] := 'B18'; // Status Reason Code oSegment.DataElementValue[2,0] := 'D8'; oSegment.DataElementValue[3,0] := '19871215'; // Date Time Period // N1 - NAME oSegment := oTransactionset.CreateDataSegment('SST\N1') as IediDataSegment; oSegment.DataElementValue[1,0] := 'HS'; // Entity Identifier Code oSegment.DataElementValue[2,0] := 'ST MARY''S HIGH SCHOOL'; // Name // N4 - GEOGRAPHIC LOCATION oSegment := oTransactionset.CreateDataSegment('SST\N4') as IediDataSegment; oSegment.DataElementValue[1,0] := 'CARSON'; // City Name oSegment.DataElementValue[2,0] := 'CA'; // State or Province Code // ATV - STUDENT ACTIVITIES AND AWARDS oSegment := oTransactionset.CreateDataSegment('ATV\ATV') as IediDataSegment; oSegment.DataElementValue[3,0] := 'HOMECOMING QUEEN'; // Entity Title // DTP - DATE OR TIME OR PERIOD oSegment := oTransactionset.CreateDataSegment('ATV\DTP') as IediDataSegment; oSegment.DataElementValue[1,0] := '103'; // Date/Time Qualifier oSegment.DataElementValue[2,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := '19871130'; // Date Time Period // ATV - STUDENT ACTIVITIES AND AWARDS oSegment := oTransactionset.CreateDataSegment('ATV(2)\ATV') as IediDataSegment; oSegment.DataElementValue[3,0] := 'ATHLETE OF THE YEAR 1985'; // Entity Title // DTP - DATE OR TIME OR PERIOD oSegment := oTransactionset.CreateDataSegment('ATV(2)\DTP') as IediDataSegment; oSegment.DataElementValue[1,0] := '103'; // Date/Time Qualifier oSegment.DataElementValue[2,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := '19851202'; // Date Time Period // TST - TEST SCORE RECORD oSegment := oTransactionset.CreateDataSegment('TST\TST') as IediDataSegment; oSegment.DataElementValue[1,0] := 'CPE'; // Educational Test or Requirement Code oSegment.DataElementValue[2,0] := 'CERTIFIED PRIMARY EDU'; // Name oSegment.DataElementValue[3,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[4,0] := '19791128'; // Date Time Period oSegment.DataElementValue[7,0] := '07'; // Level of Individual, Test, or Course Code // SBT - SUBTEST oSegment := oTransactionset.CreateDataSegment('TST\SBT\SBT') as IediDataSegment; oSegment.DataElementValue[1,0] := 'TOTAL'; // Subtest Code // SRE - TEST SCORES oSegment := oTransactionset.CreateDataSegment('TST\SBT\SRE') as IediDataSegment; oSegment.DataElementValue[1,0] := '3'; // Test Score Qualifier Code oSegment.DataElementValue[2,0] := 'ABA'; // Description // TST - TEST SCORE RECORD oSegment := oTransactionset.CreateDataSegment('TST(2)\TST') as IediDataSegment; oSegment.DataElementValue[1,0] := 'OLV'; // Educational Test or Requirement Code oSegment.DataElementValue[2,0] := 'O-LEVEL'; // Name oSegment.DataElementValue[3,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[4,0] := '19831130'; // Date Time Period oSegment.DataElementValue[7,0] := '07'; // Level of Individual, Test, or Course Code // SBT - SUBTEST oSegment := oTransactionset.CreateDataSegment('TST(2)\SBT\SBT') as IediDataSegment; oSegment.DataElementValue[1,0] := 'TOTAL'; // Subtest Code // SRE - TEST SCORES oSegment := oTransactionset.CreateDataSegment('TST(2)\SBT\SRE') as IediDataSegment; oSegment.DataElementValue[1,0] := '3'; // Test Score Qualifier Code oSegment.DataElementValue[2,0] := '16'; // Description // TST - TEST SCORE RECORD oSegment := oTransactionset.CreateDataSegment('TST(3)\TST') as IediDataSegment; oSegment.DataElementValue[1,0] := 'ALV'; // Educational Test or Requirement Code oSegment.DataElementValue[2,0] := 'A-LEVEL'; // Name oSegment.DataElementValue[3,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[4,0] := '19861129'; // Date Time Period oSegment.DataElementValue[7,0] := '07'; // Level of Individual, Test, or Course Code // SBT - SUBTEST oSegment := oTransactionset.CreateDataSegment('TST(3)\SBT\SBT') as IediDataSegment; oSegment.DataElementValue[1,0] := 'TOTAL'; // Subtest Code // SRE - TEST SCORES oSegment := oTransactionset.CreateDataSegment('TST(3)\SBT\SRE') as IediDataSegment; oSegment.DataElementValue[1,0] := '3'; // Test Score Qualifier Code oSegment.DataElementValue[2,0] := 'A'; // Description // LX - ASSIGNED NUMBER oSegment := oTransactionset.CreateDataSegment('LX\LX') as IediDataSegment; oSegment.DataElementValue[1,0] := '123456'; // Assigned Number // HS - HEALTH SCREENING oSegment := oTransactionset.CreateDataSegment('LX\HS') as IediDataSegment; oSegment.DataElementValue[1,0] := 'IDIDID'; // Health Screening Type Code oSegment.DataElementValue[2,0] := 'CC'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := 'A1B2C3D4E5'; // Date Time Period oSegment.DataElementValue[4,0] := '001'; // Status Reason Code // IMM - IMMUNIZATION STATUS CODE oSegment := oTransactionset.CreateDataSegment('LX\IMM') as IediDataSegment; oSegment.DataElementValue[1,0] := 'FLU'; // Immunization Type Code oSegment.DataElementValue[2,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := '19871128'; // Date Time Period oSegment.DataElementValue[4,0] := '1'; // IMM - IMMUNIZATION STATUS CODE oSegment := oTransactionset.CreateDataSegment('LX\IMM(2)') as IediDataSegment; oSegment.DataElementValue[1,0] := 'TETANU'; // Immunization Type Code oSegment.DataElementValue[2,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := '19700219'; // Date Time Period oSegment.DataElementValue[4,0] := '1'; // IMM - IMMUNIZATION STATUS CODE oSegment := oTransactionset.CreateDataSegment('LX\IMM(3)') as IediDataSegment; oSegment.DataElementValue[1,0] := 'MUMPS'; // Immunization Type Code oSegment.DataElementValue[2,0] := 'D8'; // Date Time Period Format Qualifier oSegment.DataElementValue[3,0] := '19750504'; // Date Time Period oSegment.DataElementValue[4,0] := '1'; // SES - ACADEMIC SESSION HEADER oSegment := oTransactionset.CreateDataSegment('LX\SES\SES') as IediDataSegment; oSegment.DataElementValue[1,0] := '20010407'; // Date Time Period oSegment.DataElementValue[4,0] := '4'; // Session Code oSegment.DataElementValue[5,0] := 'SPRING QUARTER 2001'; // Name oSegment.DataElementValue[6,0] := 'D8'; oSegment.DataElementValue[7,0] := '20010407'; // Date Time Period oSegment.DataElementValue[8,0] := 'D8'; oSegment.DataElementValue[9,0] := '20010630'; // Date Time Period oSegment.DataElementValue[10,0] := '21'; // Level of Individual, Test, or Course Code oSegment.DataElementValue[14,0] := 'B35'; // Status Reason Code // CRS - COURSE RECORD oSegment := oTransactionset.CreateDataSegment('LX\SES\CRS\CRS') as IediDataSegment; oSegment.DataElementValue[1,0] := 'R'; // Basis for Academic Credit Code oSegment.DataElementValue[2,0] := 'U'; // Academic Credit Type Code oSegment.DataElementValue[5,0] := 'GRD'; oSegment.DataElementValue[6,0] := 'AB'; // Academic Grade oSegment.DataElementValue[8,0] := 'U'; // Academic Grade or Course Level Code oSegment.DataElementValue[12,0] := '12'; // Quantity oSegment.DataElementValue[14,0] := 'BEGIN MATH'; // Name oSegment.DataElementValue[15,0] := 'MAT101'; // Reference Identification oSegment.DataElementValue[16,0] := 'MATH'; // Name // SES - ACADEMIC SESSION HEADER oSegment := oTransactionset.CreateDataSegment('LX\SES(2)\SES') as IediDataSegment; oSegment.DataElementValue[1,0] := '200106020'; // Date Time Period oSegment.DataElementValue[4,0] := '4'; // Session Code oSegment.DataElementValue[5,0] := 'SUMMER QUARTER 2001'; // Name oSegment.DataElementValue[6,0] := 'D8'; oSegment.DataElementValue[7,0] := '20010620'; // Date Time Period oSegment.DataElementValue[8,0] := 'D8'; oSegment.DataElementValue[9,0] := '20010915'; // Date Time Period oSegment.DataElementValue[10,0] := '21'; // Level of Individual, Test, or Course Code oSegment.DataElementValue[14,0] := 'B35'; // Status Reason Code // CRS - COURSE RECORD oSegment := oTransactionset.CreateDataSegment('LX\SES(2)\CRS\CRS') as IediDataSegment; oSegment.DataElementValue[1,0] := 'R'; // Basis for Academic Credit Code oSegment.DataElementValue[2,0] := 'U'; // Academic Credit Type Code oSegment.DataElementValue[5,0] := 'GRD'; oSegment.DataElementValue[6,0] := 'AB'; // Academic Grade oSegment.DataElementValue[8,0] := 'U'; // Academic Grade or Course Level Code oSegment.DataElementValue[12,0] := '12'; // Quantity oSegment.DataElementValue[14,0] := 'BEGIN CHEM'; // Name oSegment.DataElementValue[15,0] := 'CHE101'; // Reference Identification oSegment.DataElementValue[16,0] := 'CHEMISTRY'; // Name // CRS - COURSE RECORD oSegment := oTransactionset.CreateDataSegment('LX\SES(2)\CRS(2)\CRS') as IediDataSegment; oSegment.DataElementValue[1,0] := 'R'; // Basis for Academic Credit Code oSegment.DataElementValue[2,0] := 'S'; // Academic Credit Type Code oSegment.DataElementValue[5,0] := 'GRD'; oSegment.DataElementValue[6,0] := 'BC'; // Academic Grade oSegment.DataElementValue[8,0] := 'U'; // Academic Grade or Course Level Code oSegment.DataElementValue[12,0] := '12'; // Quantity oSegment.DataElementValue[14,0] := 'BEGIN PHYSICS'; // Name oSegment.DataElementValue[15,0] := 'PHY101'; // Reference Identification oSegment.DataElementValue[16,0] := 'PHYSICS'; // Name // TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS (SAVES) // THE EDI DOCUMENT OBJECT INTO AN EDI FILE. oEdidoc.Save(sPath + sEdiFile,0); ShowMessage('Done. Output = ' + sPath + sEdiFile); end;