* This is just an example to show how to translate an EDI X12 130 Student Educational Record (Transcript) * in Foxpro with Framework EDI component clear * CREATES EDIDOC 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 TRANSLATE THE EDI FILE. oSchemas = oEdiDoc.GetSchemas oSchemas.EnableStandardReference = .F. * THIS OPTIONS STOPS FREDI FROM KEEPING ALL THE SEGMENTS IN MEMORY oEdiDoc.CursorType = 1 * LOADS THE SEF FILE oEdiDoc.LoadSchema("130_4010.SEF", 0) * LOADS THE EDI FILE oEdiDoc.LoadEdi("130.x12") * GETS THE FIRST DATA SEGMENT oSegment = oEdiDoc.FirstDataSegment * LOOP THAT WILL TRAVERSE THRU EDI FILE FROM TOP TO BOTTOM do while !isnull(oSegment) * DATA SEGMENTS WILL BE IDENTIFIED BY THEIR ID, THE LOOP SECTION AND AREA * (OR TABLE) NUMBER THAT THEY ARE IN. sSegmentID = oSegment.ID sLoopID = oSegment.LoopSection nArea = oSegment.Area do case case nArea = 0 do case case sLoopID == "" do case case sSegmentID = "ISA" sValue = oSegment.DataElementValue(1) && Authorization Information Qualifier sValue = oSegment.DataElementValue(2) && Authorization Information sValue = oSegment.DataElementValue(3) && Security Information Qualifier sValue = oSegment.DataElementValue(4) && Security Information sValue = oSegment.DataElementValue(5) && Interchange ID Qualifier sValue = oSegment.DataElementValue(6) && Interchange Sender ID sValue = oSegment.DataElementValue(7) && Interchange ID Qualifier sValue = oSegment.DataElementValue(8) && Interchange Receiver ID sValue = oSegment.DataElementValue(9) && Interchange Date sValue = oSegment.DataElementValue(10) && Interchange Time sValue = oSegment.DataElementValue(11) && Interchange Control Standards Identifier sValue = oSegment.DataElementValue(12) && Interchange Control Version Number ? oSegment.DataElement(13).Description + " = " + oSegment.DataElementValue(13) && Interchange Control Number sValue = oSegment.DataElementValue(14) && Acknowledgment Requested sValue = oSegment.DataElementValue(15) && Usage Indicator sValue = oSegment.DataElementValue(16) && Component Element Separator case sSegmentID = "GS" sValue = oSegment.DataElementValue(1) && Functional Identifier Code sValue = oSegment.DataElementValue(2) && Application Sender's Code sValue = oSegment.DataElementValue(3) && Application Receiver's Code sValue = oSegment.DataElementValue(4) && Date sValue = oSegment.DataElementValue(5) && Time ? oSegment.DataElement(6).Description + " = " + oSegment.DataElementValue(6) && Group Control Number sValue = oSegment.DataElementValue(7) && Responsible Agency Code sValue = oSegment.DataElementValue(8) && Version / Release / Industry Identifier Code endcase && sSegmentID endcase && sLoopID case nArea = 1 do case case sLoopID == "" do case case sSegmentID = "ST" sValue = oSegment.DataElementValue(1) && Transaction Set Identifier Code ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Transaction Set Control Number case sSegmentID = "BGN" sValue = oSegment.DataElementValue(1) && Transaction Set Purpose Code ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Reference Identification sValue = oSegment.DataElementValue(3) && Date sValue = oSegment.DataElementValue(4) && Time sValue = oSegment.DataElementValue(5) && Time Code case sSegmentID = "ERP" sValue = oSegment.DataElementValue(1) && Transaction Type Code sValue = oSegment.DataElementValue(2) && Status Reason Code case sSegmentID = "REF" sValue = oSegment.DataElementValue(1) && Reference Identification Qualifier ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Reference Identification endcase && sSegmentID case sLoopID == "N1" * If loop has more that one instance, then you should check for the qualifier that differentiates the loop instances here e.g. If sSegmentID = "N1" then sN1LoopQlfr = oSegment.DataElementValue(1) && In most cases the loop qualifier is the first element of the first segment in the loop, but not necessarily EndIf do case case sN1LoopQlfr = "AS" && Post Secondary Education Sender do case case sSegmentID = "N1" sValue = oSegment.DataElementValue(1) && Entity Identifier Code ? oSegment.DataElement(2).Description + " Sender = " + oSegment.DataElementValue(2) && Name case sSegmentID = "N3" ? oSegment.DataElement(1).Description + " Sender = " + oSegment.DataElementValue(1) && Address Information case sSegmentID = "N4" ? oSegment.DataElement(1).Description + " Sender = " + oSegment.DataElementValue(1) && City Name endcase && sSegmentID case sN1LoopQlfr = "AT" && Post Secondary Education Receiver do case case sSegmentID = "N1" sValue = oSegment.DataElementValue(1) && Entity Identifier Code ? oSegment.DataElement(2).Description + " Receiver = " + oSegment.DataElementValue(2) && Name case sSegmentID = "N3" ? oSegment.DataElement(1).Description + " Receiver = " + oSegment.DataElementValue(1) && Address Information case sSegmentID = "N4" ? oSegment.DataElement(1).Description + " Receiver = " + oSegment.DataElementValue(1) && City Name endcase && sSegmentID endcase && sN1LoopQlfr case sLoopID == "IN1" do case case sSegmentID = "IN1" sValue = oSegment.DataElementValue(1) && Entity Type Qualifier sValue = oSegment.DataElementValue(2) && Name Type Code case sSegmentID = "IN2" sValue = oSegment.DataElementValue(1) && Name Component Qualifier sValue = oSegment.DataElementValue(2) && Name endcase && sSegmentID case sLoopID == "SST" do case case sSegmentID = "SST" sValue = oSegment.DataElementValue(1) && Status Reason Code sValue = oSegment.DataElementValue(2) && Date Time Period Format Qualifier ? oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3) && Date Time Period case sSegmentID = "N1" sValue = oSegment.DataElementValue(1) && Entity Identifier Code ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Name case sSegmentID = "N4" ? oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1) && City Name ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && State or Province Code endcase && sSegmentID case sLoopID == "ATV" do case case sSegmentID = "ATV" sValue = oSegment.DataElementValue(1) && Code List Qualifier Code sValue = oSegment.DataElementValue(2) && Industry Code ? oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3) && Entity Title case sSegmentID = "DTP" sValue = oSegment.DataElementValue(1) && Date/Time Qualifier sValue = oSegment.DataElementValue(2) && Date Time Period Format Qualifier ? oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3) && Date Time Period endcase && sSegmentID case sLoopID == "TST" do case case sSegmentID = "TST" sValue = oSegment.DataElementValue(1) && Educational Test or Requirement Code ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Name sValue = oSegment.DataElementValue(3) && Date Time Period Format Qualifier sValue = oSegment.DataElementValue(4) && Date Time Period sValue = oSegment.DataElementValue(5) && Reference Identification sValue = oSegment.DataElementValue(6) && Reference Identification sValue = oSegment.DataElementValue(7) && Level of Individual, Test, or Course Code endcase && sSegmentID case sLoopID == "TST;SBT" do case case sSegmentID = "SBT" sValue = oSegment.DataElementValue(1) && Subtest Code case sSegmentID = "SRE" sValue = oSegment.DataElementValue(1) && Test Score Qualifier Code ? oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2) && Description endcase && sSegmentID endcase && sLoopID case nArea = 2 do case case sLoopID == "LX" do case case sSegmentID = "LX" sValue = oSegment.DataElementValue(1) && Assigned Number case sSegmentID = "HS" sValue = oSegment.DataElementValue(1) && Health Screening Type Code sValue = oSegment.DataElementValue(2) && Date Time Period Format Qualifier sValue = oSegment.DataElementValue(3) && Date Time Period sValue = oSegment.DataElementValue(4) && Status Reason Code case sSegmentID = "IMM" sValue = oSegment.DataElementValue(1) && Immunization Type Code sValue = oSegment.DataElementValue(2) && Date Time Period Format Qualifier sValue = oSegment.DataElementValue(3) && Date Time Period sValue = oSegment.DataElementValue(4) && Immunization Status Code endcase && sSegmentID case sLoopID == "LX;SES" do case case sSegmentID = "SES" sValue = oSegment.DataElementValue(1) && Date Time Period sValue = oSegment.DataElementValue(2) && Count sValue = oSegment.DataElementValue(3) && Date Time Period sValue = oSegment.DataElementValue(4) && Session Code ? oSegment.DataElement(5).Description + " = " + oSegment.DataElementValue(5) && Name sValue = oSegment.DataElementValue(6) && Date Time Period Format Qualifier sValue = oSegment.DataElementValue(7) && Date Time Period sValue = oSegment.DataElementValue(8) && Date Time Period Format Qualifier sValue = oSegment.DataElementValue(9) && Date Time Period sValue = oSegment.DataElementValue(10) && Level of Individual, Test, or Course Code sValue = oSegment.DataElementValue(11) && Identification Code Qualifier sValue = oSegment.DataElementValue(12) && Identification Code sValue = oSegment.DataElementValue(13) && Name sValue = oSegment.DataElementValue(14) && Status Reason Code endcase && sSegmentID case sLoopID == "LX;SES;CRS" do case case sSegmentID = "CRS" sValue = oSegment.DataElementValue(1) && Basis for Academic Credit Code sValue = oSegment.DataElementValue(2) && Academic Credit Type Code sValue = oSegment.DataElementValue(3) && Quantity sValue = oSegment.DataElementValue(4) && Quantity sValue = oSegment.DataElementValue(5) && Academic Grade Qualifier ? oSegment.DataElement(6).Description + " = " + oSegment.DataElementValue(6) && Academic Grade sValue = oSegment.DataElementValue(7) && Yes/No Condition or Response Code sValue = oSegment.DataElementValue(8) && Academic Grade or Course Level Code sValue = oSegment.DataElementValue(9) && Course Repeat or No Count Indicator Code sValue = oSegment.DataElementValue(10) && Identification Code Qualifier sValue = oSegment.DataElementValue(11) && Identification Code sValue = oSegment.DataElementValue(12) && Quantity sValue = oSegment.DataElementValue(13) && Level of Individual, Test, or Course Code ? oSegment.DataElement(14).Description + " = " + oSegment.DataElementValue(14) && Name sValue = oSegment.DataElementValue(15) && Reference Identification sValue = oSegment.DataElementValue(16) && Name endcase && sSegmentID endcase && sLoopID endcase && nArea * GETS THE NEXT DATA SEGMENT oSegment = oSegment.Next enddo