| EDIdEv - Electronic Data Interchange Development | EDIdEv |
|
EDI Tool for Developers |
Sample EDI X12 810 Invoice generator[Run Program] [Download program] 'The main part of this procedure takes values from the form fields (and some from fixed values) 'then maps them to the data element property of the Framework EDI object. The Framework EDI 'component does the rest! It automatically constructs the EDI file by following the implementation 'guideline contained in the SEF file. 'The constructed EDI file is obtained by the GetEdiString method and then displayed onto the web page. Dim oEdiDoc As ediDocument
Dim oInterchange As ediInterchange
Dim oGroup As ediGroup
Dim oTransactionset As ediTransactionSet
Dim oSegment As ediDataSegment
Dim i As Short
Dim sInstance As String
Dim s As String
'Instantiate oEdiDoc object
oEdiDoc.Set(oEdiDoc, New ediDocument)
'use CR/LF as segment terminator in EDI file
oEdiDoc.SegmentTerminator = vbCrLf
'change cursor type to forward write to use less memory and improve performance
oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardWrite
'increase buffer so that hard drive does not become a 'bottle-neck'
oEdiDoc.Property(DocumentPropertyIDConstants.Property_DocumentBufferIO) = 200
'load standard exchange format (SEF) file
oEdiDoc.LoadSchema("d:\Inetpub\wwwroot\edidev-ca\samples\vbNetGen\bin\810_X12-4010.SEF", 0)
'Create ISA segment
oInterchange.Set(oInterchange, oEdiDoc.CreateInterchange("X", "004010"))
oSegment.Set(oSegment, oInterchange.GetDataSegmentHeader)
oSegment.DataElementValue(1) = "00"
oSegment.DataElementValue(3) = "00"
oSegment.DataElementValue(5) = "ZZ"
oSegment.DataElementValue(6) = "SENDERISA"
oSegment.DataElementValue(7) = "ZZ"
oSegment.DataElementValue(8) = "RECEIVERISA"
oSegment.DataElementValue(9) = "960807"
oSegment.DataElementValue(10) = "1548"
oSegment.DataElementValue(11) = "U"
oSegment.DataElementValue(12) = "00401"
oSegment.DataElementValue(13) = "000000020"
oSegment.DataElementValue(14) = "0"
oSegment.DataElementValue(15) = "T"
oSegment.DataElementValue(16) = ">"
'Creates GS segment
oGroup.Set(oGroup, oInterchange.CreateGroup("004010"))
oSegment.Set(oSegment, oGroup.GetDataSegmentHeader)
oSegment.DataElementValue(1) = "IN"
oSegment.DataElementValue(2) = "SENDERDEPT"
oSegment.DataElementValue(3) = "007326879"
oSegment.DataElementValue(4) = "19960807"
oSegment.DataElementValue(5) = "1548"
oSegment.DataElementValue(6) = "000001"
oSegment.DataElementValue(7) = "X"
oSegment.DataElementValue(8) = "004010"
'create ST segment
oTransactionset.Set(oTransactionset, oGroup.CreateTransactionSet("810"))
oSegment.Set(oSegment, oTransactionset.GetDataSegmentHeader)
oSegment.DataElementValue(2) = "10001"
'create BIG segment
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("BIG"))
oSegment.DataElementValue(1) = "20021208"
oSegment.DataElementValue(2) = "00001"
oSegment.DataElementValue(4) = "A999"
'Creates N1 Loops
'Ship To information
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(1)\N1"))
oSegment.DataElementValue(1) = "ST"
oSegment.DataElementValue(2) = txtShipToCompany.Text
oSegment.DataElementValue(3) = "9"
oSegment.DataElementValue(4) = "122334455"
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(1)\N3"))
oSegment.DataElementValue(1) = txtShipToAddr.Text
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(1)\N4"))
oSegment.DataElementValue(1) = txtShipToCity.Text
oSegment.DataElementValue(2) = txtShipToState.Text
oSegment.DataElementValue(3) = txtShipToZip.Text
'Bill-to information
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(2)\N1"))
oSegment.DataElementValue(1) = "BT"
oSegment.DataElementValue(2) = txtBillToCompany.Text
oSegment.DataElementValue(3) = "9"
oSegment.DataElementValue(4) = "122334455"
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(2)\N3"))
oSegment.DataElementValue(1) = txtBillToAddr.Text
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("N1(2)\N4"))
oSegment.DataElementValue(1) = txtBillToCity.Text
oSegment.DataElementValue(2) = txtBillToState.Text
oSegment.DataElementValue(3) = txtBillToZip.Text
'Terms
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("ITD"))
oSegment.DataElementValue(1) = "01"
oSegment.DataElementValue(2) = "3"
oSegment.DataElementValue(3) = "2"
oSegment.DataElementValue(5) = "30"
oSegment.DataElementValue(7) = "30"
oSegment.DataElementValue(12) = "60"
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("FOB"))
oSegment.DataElementValue(1) = "PP"
'Creates the item detail Loop
For i = 1 To 1
sInstance = Trim(Str(i))
'creates the IT1 segment in the IT1 loop
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("IT1(" & sInstance & ")\IT1"))
oSegment.DataElementValue(2) = txtQty.Text
oSegment.DataElementValue(3) = "EA"
oSegment.DataElementValue(4) = "1200"
oSegment.DataElementValue(6) = "UA"
oSegment.DataElementValue(7) = "EAN"
'creates the PID segment in the IT1\PID loop
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("IT1(" & sInstance & ")\PID\PID"))
oSegment.DataElementValue(1) = "F"
oSegment.DataElementValue(5) = txtItem.Text
Next 'Creates the TDS segment
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("TDS"))
oSegment.DataElementValue(1) = 20 * 100
'Creates the CAD segment
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("CAD"))
oSegment.DataElementValue(5) = "Routing"
'Creates the ISS segment in Loop ISS, then populates its elements
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("ISS\ISS"))
oSegment.DataElementValue(1) = "30"
oSegment.DataElementValue(2) = "CA"
'Creates the CTT segment
oSegment.Set(oSegment, oTransactionset.CreateDataSegment("CTT"))
oSegment.DataElementValue(1) = 50
'gets the EDI file as a string
s = oEdiDoc.GetEdiString(0)
'display EDI string
TextBox1.Text = s
|
EDIdEv - EDI Development
www.edidev.com