* This is just an example program to show how to generate an EDI X12 130 Student Educational Record
* in FoxPro with Framework EDI component
clear
* CREATES EDI DOCUMENT OBJECT
oEdiDoc = createobject("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.
oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = .F.
* 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
oSchema = oEdiDoc.LoadSchema("130_4010.SEF", 0)
* CREATES THE ISA SEGMENT
oInterchange = oEdiDoc.CreateInterchange("X","004010")
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) = "061206" && 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
oGroup = oInterchange.CreateGroup("004010")
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
oTransactionset = oGroup.CreateTransactionSet("130")
oSegment = oTransactionset.GetDataSegmentHeader
oSegment.DataElementValue(1) = "130" && Transaction Set Identifier Code
oSegment.DataElementValue(2) = "0001" && Transaction Set Control Number
* BGN - BEGINNING SEGMENT
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
oSegment = oTransactionset.CreateDataSegment("ERP")
oSegment.DataElementValue(1) = "PS" && Transaction Type Code
oSegment.DataElementValue(2) = "INF" && Status Reason Code
* REF - REFERENCE IDENTIFICATION
oSegment = oTransactionset.CreateDataSegment("REF")
oSegment.DataElementValue(1) = "SY" && Reference Identification Qualifier
oSegment.DataElementValue(2) = "12345679" && Reference Identification
* N1 - NAME
* create N1 segment in N1 loop
oSegment = oTransactionset.CreateDataSegment("N1\N1")
oSegment.DataElementValue(1) = "AS" && Entity Identifier Code
oSegment.DataElementValue(2) = "UNIVERSITY SENDER" && Name
* N3 - ADDRESS INFORMATION
* create N3 segment in N1 loop
oSegment = oTransactionset.CreateDataSegment("N1\N3")
oSegment.DataElementValue(1) = "123 SENDER AVENUE" && Address Information
* N4 - GEOGRAPHIC LOCATION
* create N4 segment in N1 loop
oSegment = oTransactionset.CreateDataSegment("N1\N4")
oSegment.DataElementValue(1) = "LOS ANGELES" && City Name
* N1 - NAME
* create N1 segment in the second instance of the N1 loop
oSegment = oTransactionset.CreateDataSegment("N1(2)\N1") && Having the loop instance counter (2) is not necessary i the syntax 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
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
oSegment = oTransactionset.CreateDataSegment("N1(2)\N4")
oSegment.DataElementValue(1) = "NEW YORK" && City Name
* IN1 - INDIVIDUAL IDENTIFICATION
oSegment = oTransactionset.CreateDataSegment("IN1\IN1")
oSegment.DataElementValue(1) = "1" && Entity Type Qualifier
oSegment.DataElementValue(2) = "04" && Name Type Code
* IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS
* create first instance of IN2 segment in IN1 loop
oSegment = oTransactionset.CreateDataSegment("IN1\IN2")
oSegment.DataElementValue(1) = "05" && Name Component Qualifier
oSegment.DataElementValue(2) = "SMITH" && Name
* IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS
* create second instance of IN2 segment in IN1 loop
oSegment = oTransactionset.CreateDataSegment("IN1\IN2(2)")
oSegment.DataElementValue(1) = "02" && Name Component Qualifier
oSegment.DataElementValue(2) = "MARY" && Name
* IN2 - INDIVIDUAL NAME STRUCTURE COMPONENTS
oSegment = oTransactionset.CreateDataSegment("IN1\IN2(3)")
oSegment.DataElementValue(1) = "15" && Name Component Qualifier
oSegment.DataElementValue(2) = "J" && Name
* SST - STUDENT ACADEMIC STATUS
oSegment = oTransactionset.CreateDataSegment("SST\SST")
oSegment.DataElementValue(1) = "B18" && Status Reason Code
oSegment.DataElementValue(2) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(3) = "19871215" && Date Time Period
* N1 - NAME
oSegment = oTransactionset.CreateDataSegment("SST\N1")
oSegment.DataElementValue(1) = "HS" && Entity Identifier Code
oSegment.DataElementValue(2) = "ST MARY'S HIGH SCHOOL" && Name
* N4 - GEOGRAPHIC LOCATION
oSegment = oTransactionset.CreateDataSegment("SST\N4")
oSegment.DataElementValue(1) = "CARSON" && City Name
oSegment.DataElementValue(2) = "CA" && State or Province Code
for nAtvLoop = 1 to 3 && number of activities
* ATV - STUDENT ACTIVITIES AND AWARDS
oSegment = oTransactionset.CreateDataSegment("ATV\ATV")
oSegment.DataElementValue(3) = "ATHLETE OF THE YEAR 1985" && Entity Title
* DTP - DATE OR TIME OR PERIOD
oSegment = oTransactionset.CreateDataSegment("ATV\DTP")
oSegment.DataElementValue(1) = "103" && Date/Time Qualifier
oSegment.DataElementValue(2) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(3) = "19871130" && Date Time Period
next
for nTstLoop = 1 to 3 && number of tests
* TST - TEST SCORE RECORD
oSegment = oTransactionset.CreateDataSegment("TST\TST")
oSegment.DataElementValue(1) = "CPE" && Educational Test or Requirement Code
oSegment.DataElementValue(2) = "CERTIFIED PRIMARY EDU" && Name
oSegment.DataElementValue(3) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(4) = "19791128" && Date Time Period
oSegment.DataElementValue(7) = "07" && Level of Individual, Test, or Course Code
* SBT - SUBTEST
oSegment = oTransactionset.CreateDataSegment("TST\SBT\SBT")
oSegment.DataElementValue(1) = "TOTAL" && Subtest Code
* SRE - TEST SCORES
oSegment = oTransactionset.CreateDataSegment("TST\SBT\SRE")
oSegment.DataElementValue(1) = "3" && Test Score Qualifier Code
oSegment.DataElementValue(2) = "ABA" && Description
next
* LX - ASSIGNED NUMBER
oSegment = oTransactionset.CreateDataSegment("LX\LX")
oSegment.DataElementValue(1) = "123456" && Assigned Number
* HS - HEALTH SCREENING
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
oSegment = oTransactionset.CreateDataSegment("LX\IMM")
oSegment.DataElementValue(1) = "FLU" && Immunization Type Code
oSegment.DataElementValue(2) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(3) = "19871128" && Date Time Period
oSegment.DataElementValue(4) = "1" && Immunization Status Code
* IMM - IMMUNIZATION STATUS CODE
oSegment = oTransactionset.CreateDataSegment("LX\IMM(2)")
oSegment.DataElementValue(1) = "TETANU" && Immunization Type Code
oSegment.DataElementValue(2) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(3) = "19700219" && Date Time Period
oSegment.DataElementValue(4) = "1" && Immunization Status Code
* IMM - IMMUNIZATION STATUS CODE
oSegment = oTransactionset.CreateDataSegment("LX\IMM(3)")
oSegment.DataElementValue(1) = "MUMPS" && Immunization Type Code
oSegment.DataElementValue(2) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(3) = "19750504" && Date Time Period
oSegment.DataElementValue(4) = "1" && Immunization Status Code
for nSesLoop = 1 to 2 && numer of sessions
* SES - ACADEMIC SESSION HEADER
oSegment = oTransactionset.CreateDataSegment("LX\SES\SES")
oSegment.DataElementValue(1) = "20010407" && Date Time Period
oSegment.DataElementValue(4) = "4" && Session Code
oSegment.DataElementValue(5) = "SPRING QUARTER 2001" && Name
oSegment.DataElementValue(6) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(7) = "20010407" && Date Time Period
oSegment.DataElementValue(8) = "D8" && Date Time Period Format Qualifier
oSegment.DataElementValue(9) = "20010630" && Date Time Period
oSegment.DataElementValue(10) = "21" && Level of Individual, Test, or Course Code
oSegment.DataElementValue(14) = "B35" && Status Reason Code
for nCrsLoop = 1 to 2 && number of courses in a session
* CRS - COURSE RECORD
oSegment = oTransactionset.CreateDataSegment("LX\SES\CRS\CRS")
oSegment.DataElementValue(1) = "R" && Basis for Academic Credit Code
oSegment.DataElementValue(2) = "U" && Academic Credit Type Code
oSegment.DataElementValue(5) = "GRD" && Academic Grade Qualifier
oSegment.DataElementValue(6) = "AB" && Academic Grade
oSegment.DataElementValue(8) = "U" && Academic Grade or Course Level Code
oSegment.DataElementValue(12) = "12" && Quantity
oSegment.DataElementValue(14) = "BEGIN MATH" && Name
oSegment.DataElementValue(15) = "MAT101" && Reference Identification
oSegment.DataElementValue(16) = "MATH" && Name
next
next
* TRAILING SEGMENTS ARE AUTOMATICALLY CREATED WHEN FREDI COMMITS (SAVES)
* THE EDI DOCUMENT OBJECT INTO AN EDI FILE.
oEdiDoc.Save("130Outbound.x12",0)
? "Done"