eConnect - SOP Create Order

This is a code sample for how to create a SOP order in eConnect. 

Objects used: SOPTransactionType, taSopHdrIvcInsert, taSopLineIvcInsert_ItemsTaSopLineIvcInsert.

You'll need the eConnectFunctions class located here: http://dyndeveloper.com/thread.aspx?Threadid=1117

 


Public Class SOPTransactionType
    Sub CreateOrder()
        'SOP Create Order
        Try
            Dim intNumberOfLines As Int16 = 0 '0 = 1 line
 
            'declare our eConnect classes
            Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
            Dim oSOPTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.SOPTransactionType
            Dim oeConnectFunctions As New eConnect11Lib.GP11.eConnectFunctions("vmGP11", "TWO")
 
            'create the document header
            Dim otaSopHdrIvcInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taSopHdrIvcInsert
 
            'populate the header
            With otaSopHdrIvcInsert
                .SOPNUMBE = "TEST01"
                .SOPTYPE = 2
                .DOCID = "STDORD"
                .CUSTNMBR = "AARONFIT0001"
                .BACHNUMB = "WEB" & Now.ToString("yyyyMMdd")
                .DOCDATE = Now.ToShortDateString
 
                .CSTPONBR = ""
                .PRSTADCD = ""
                .PRBTADCD = ""
                .SHIPMTHD = ""
                .PYMTRMID = ""
                .COMMENT_1 = "" '50 characters
                .ReqShipDate = Now.ToShortDateString
 
                .FREIGHT = 0
                .MISCAMNT = 0
                .FRTTXAMT = 0
                .MSCTXAMT = 0
                .TRDISAMT = 0
                .LOCNCODE = "WAREHOUSE"
                .PYMTRMID = "CREDIT CARD"
                .INTEGRATIONID = ""
            End With
 
            'assign the header to the master
            oSOPTransactionType.taSopHdrIvcInsert = otaSopHdrIvcInsert
 
            'create the document details
            For intCurrentLine As Int16 = 0 To intNumberOfLines
                'declare an object for the detail line
                Dim oItemsTaSopLineIvcInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taSopLineIvcInsert_ItemsTaSopLineIvcInsert
 
                'populate the detail line
                oItemsTaSopLineIvcInsert.SOPNUMBE = "TEST01"
                oItemsTaSopLineIvcInsert.SOPTYPE = 2
                oItemsTaSopLineIvcInsert.ITEMNMBR = "100XLG"
                oItemsTaSopLineIvcInsert.QUANTITY = 1
                oItemsTaSopLineIvcInsert.CUSTNMBR = "AARONFIT0001"
                oItemsTaSopLineIvcInsert.DOCDATE = Now.ToShortDateString
 
                ReDim Preserve oSOPTransactionType.taSopLineIvcInsert_Items(intCurrentLine)
                oSOPTransactionType.taSopLineIvcInsert_Items(intCurrentLine) = oItemsTaSopLineIvcInsert
            Next
 
 
            ReDim Preserve oeConnectType.SOPTransactionType(0)
            oeConnectType.SOPTransactionType(0) = oSOPTransactionType
            oeConnectFunctions.CreateTransactionEntity(oeConnectType)
            MsgBox("done")
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
    End Sub
End Class


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences