eConnect - Update the header of a SOP Document

This is code sample for updating the header of a SOP document. We use the SOPTransactionType and taSopHdrIvcInsert eConnect objects.

Edit 3/29/2021

Please see the comments below for some user feedback. We appreciate the feedback!

 

    Sub UpdateSOPOrder(ByVal strSOPNUMBE As StringByVal intSOPTYPE As Int16ByVal decFREIGHT As Decimal)
        Try
            Dim intNumberOfLines As Int16 = 0 '0 = 1 line
 
            'simulate sql code here to get information about the order
            Dim strDOCID As String = "STDINV"
            Dim strCUSTNMBR As String = "AARONFIT0001"
            Dim dtDocDate As Date = "1/19/2012"
            Dim strBACHNUMB As String = "INVS"
 
            'declare our eConnect classes
            Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
            Dim oSOPTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.SOPTransactionType
            'this is our custom eConnect Class, you can find it here: http://dyndeveloper.com/thread.aspx?Threadid=1117
            Dim oeConnectFunctions As New GP11.eConnectFunctions("vmGP11""TWO")
 
            'create the document header
            Dim otaSopHdrIvcInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taSopHdrIvcInsert
 
            'populate the header
            With otaSopHdrIvcInsert
                'these are the required fields
                .SOPNUMBE = strSOPNUMBE
                .SOPTYPE = intSOPTYPE
                .DOCID = strDOCID
                .CUSTNMBR = strCUSTNMBR
                .DOCDATE = dtDocDate
                .BACHNUMB = strBACHNUMB
                .UpdateExisting = 1
 
                'this is the field that we're updating. 
                .FREIGHT = decFREIGHT
            End With
 
            'assign the header to the master
            oSOPTransactionType.taSopHdrIvcInsert = otaSopHdrIvcInsert
 
            ReDim Preserve oeConnectType.SOPTransactionType(0)
            oeConnectType.SOPTransactionType(0) = oSOPTransactionType
            oeConnectFunctions.CreateTransactionEntity(oeConnectType)
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
    End Sub

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