EDIdEv - Electronic Data Interchange Development    EDIdEv


 
EDI X12 Outbound

  EDI Tool for Developers

[View and run similar VB.NET source code]

Below is source code of a Visual Basic program that uses Framework EDI to generate an EDI file.

Private Sub cmdGenerate810_Click()

Dim oEdiDoc As Fredi.ediDocument
Dim oInterchange As Fredi.ediInterchange
Dim oGroup As Fredi.ediGroup
Dim oTransactionset As Fredi.ediTransactionSet
Dim oSegment As Fredi.ediDataSegment
Dim sSefFile As String
Dim sEdiFile As String

sSefFile = sPath & "810_X12-4010.SEF"
sEdiFile = sPath & "810OUTPUT.x12"

Set oEdiDoc = New Fredi.ediDocument
oEdiDoc.LoadSchema sSefFile, Schema_Standard_Exchange_Format

oEdiDoc.SegmentTerminator = "~" & vbCrLf
oEdiDoc.ElementTerminator = "*"
oEdiDoc.CompositeTerminator = ">"

'CREATES THE ISA SEGMENT
Set oInterchange = oEdiDoc.CreateInterchange("X", "004010")
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 THE GS SEGMENT
Set oGroup = oInterchange.CreateGroup("004010")
Set oSegment = oGroup.GetDataSegmentHeader
oSegment.DataElementValue(1) = "IN"
oSegment.DataElementValue(2) = "SENDERDEPT"
oSegment.DataElementValue(3) = "RECEIVERDEPT"
oSegment.DataElementValue(4) = "19960807"
oSegment.DataElementValue(5) = "1548"
oSegment.DataElementValue(6) = "1"
oSegment.DataElementValue(7) = "X"
oSegment.DataElementValue(8) = "004010"

'CREATES THE ST SEGMENT
Set oTransactionset = oGroup.CreateTransactionSet("810")
Set oSegment = oTransactionset.GetDataSegmentHeader
oSegment.DataElementValue(2) = "000000001"

'CREATES THE BIG SEGMENT
Set oSegment = oTransactionset.CreateDataSegment("BIG")
oSegment.DataElementValue(1) = txtShippedDate.Text
oSegment.DataElementValue(2) = txtInvoiceNo.Text
oSegment.DataElementValue(4) = txtPONumber.Text

'CREATES THE N1 SEGMENT IN LOOP N1 (SHIP TO)
Set oSegment = oTransactionset.CreateDataSegment("N1\N1")
oSegment.DataElementValue(1) = "ST"
oSegment.DataElementValue(2) = txtShipToName.Text
oSegment.DataElementValue(3) = "9"
oSegment.DataElementValue(4) = txtShipToDUNS.Text

'CREATES THE N3 SEGMENT IN LOOP N1 (SHIP TO)
Set oSegment = oTransactionset.CreateDataSegment("N1\N3")
oSegment.DataElementValue(1) = txtShipToAddress.Text

'CREATES THE N4 SEGMENT IN LOOP N1 (SHIP TO)
Set oSegment = oTransactionset.CreateDataSegment("N1\N4")
oSegment.DataElementValue(1) = txtShipToCity.Text
oSegment.DataElementValue(2) = txtShipToState.Text
oSegment.DataElementValue(3) = txtShipToZip.Text

'CREATES THE N1 SEGMENT IN LOOP N1 (BILL TO)
Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N1")
oSegment.DataElementValue(1) = "BT"
oSegment.DataElementValue(2) = txtBillToName.Text
oSegment.DataElementValue(3) = "9"
oSegment.DataElementValue(4) = txtBillToDUNS.Text

'CREATES THE N3 SEGMENT IN LOOP N1 (BILL TO)
Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N3")
oSegment.DataElementValue(1) = txtBillToAddress.Text

'CREATES THE N4 SEGMENT IN LOOP N1 (BILL TO)
Set oSegment = oTransactionset.CreateDataSegment("N1(2)\N4")
oSegment.DataElementValue(1) = txtBillToCity.Text
oSegment.DataElementValue(2) = txtBillToState.Text
oSegment.DataElementValue(3) = txtBillToZip.Text

'SAVES THE EDI FILE
oEdiDoc.Save sEdiFile

End Sub

The sample program above is to demonstrate how one can easily use the Framework EDI component to create an EDI file.  The component manages the arduous detail of the EDI file structure so that programmers generating EDI files can just simply "map" their input variables into the properties of the component in their program.  

Outbound mapping is the process of specifying a variable from an existing system (e.g. a database field) to an EDI data element.  The advantages of having the mapping done at the source code level (as compared to at an application level)  are flexibility, robustness and accuracy.

Click here to download more sample programs

Click here to download Framework EDI

  Home
    Generate EDI <
    Translate EDI
    Acknowledge EDI
    Transmit by TCP/IP
    Product Information

  Evaluate Framework EDI

  Source Code Examples

  Purchase

  Support

  About EDIdEv LLC

 

EDIdEv - EDI Development
www.edidev.com