eConnect - Update one line in a SOP document

This is a code example for how to update one line in a SOP document using eConnect for GP2010.

There are a certain number of fields that need to be populated in the documents, we've shown those. You can include additional fields if you need them.

Imports Microsoft.Dynamics.GP.eConnect.Serialization
 
 
Public Class SOPUPdateSOPLine
    Private _sopnumbe As String
    Private _soptype As Int16
    Private _lnitmseq As Int32
    Private _server As String
    Private _db As String
    Private oSOP10100 As DAAB.SOP10100
    Private oSOP10200 As DAAB.SOP10200
 
    Public otaSopLineIvcInsert_ItemsTaSopLineIvcInsert As New taSopLineIvcInsert_ItemsTaSopLineIvcInsert
    Public otaSopHdrIvcInsert As New taSopHdrIvcInsert
 
    Sub New(ByVal SOPNUMBE As StringByVal SOPTYPE As Int16ByVal LNITMSEQ As Int32ByVal SERVER As StringByVal DB As String)
        _sopnumbe = SOPNUMBE
        _soptype = SOPTYPE
        _lnitmseq = LNITMSEQ
        _server = SERVER
        _db = DB
 
        'create an object for the line item, and populate it with data from GP
        'these classes are documented here: 
        oSOP10200 = New DAAB.SOP10200(SOPTYPE, SOPNUMBE, LNITMSEQ, 0, DB)
        oSOP10100 = New DAAB.SOP10100(SOPTYPE, SOPNUMBE, DB)
 
    End Sub
    Sub Update()
        'initialize
        Dim strDoc As String = ""
        Dim bResult As Boolean = False
 
        'create the service reference
        Dim oeConnectFunctions As New eConnect11Lib.GP11.eConnectFunctions(_server, _db)
 
        Try
            'Create eConnect Objects
            Dim oeConnectType As New eConnectType
            Dim oSOPTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.SOPTransactionType
            Dim otaSopLineIvcInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taSopLineIvcInsert_ItemsTaSopLineIvcInsert
            With otaSopLineIvcInsert
                'minimum required fields to get the doc to go through
                .SOPNUMBE = oSOP10200.SOPNUMBE
                .SOPTYPE = oSOP10200.SOPTYPE
                .QUANTITY = oSOP10200.QUANTITY + 1
                .DOCDATE = oSOP10100.DOCDATE
                .CUSTNMBR = oSOP10100.CUSTNMBR
                .ITEMNMBR = oSOP10200.ITEMNMBR
 
                'these fields are not required, but they will be 0 or '' if the value is not set
                .UNITPRCE = oSOP10200.UNITPRCE
                .XTNDPRCE = .UNITPRCE * .QUANTITY
                .PRCLEVEL = oSOP10200.PRCLEVEL
                .UpdateIfExists = 1
            End With
 
            'assign the SOP line to the SOP document
            ReDim oSOPTransactionType.taSopLineIvcInsert_Items(0)
            oSOPTransactionType.taSopLineIvcInsert_Items(0) = otaSopLineIvcInsert
 
            'assign the SOP header to the SOP document
            With otaSopHdrIvcInsert
                'minimum required fields to get the doc to go through
                .SOPNUMBE = oSOP10200.SOPNUMBE
                .SOPTYPE = oSOP10200.SOPTYPE
                .DOCDATE = oSOP10100.DOCDATE
                .CUSTNMBR = oSOP10100.CUSTNMBR
                .DOCID = oSOP10100.DOCID
                .BACHNUMB = oSOP10100.BACHNUMB
                .UpdateExisting = 1
            End With
            oSOPTransactionType.taSopHdrIvcInsert = otaSopHdrIvcInsert
 
            'assign the document to the eConnectType
            ReDim oeConnectType.SOPTransactionType(0)
            oeConnectType.SOPTransactionType(0) = oSOPTransactionType
 
            'send the transaction
            'the eConnectFunctions class is documented here:http://dyndeveloper.com/thread.aspx?Threadid=1117
            bResult = oeConnectFunctions.UpdateTransactionEntity(oeConnectType)
 
        Catch ex As Exception
            Dim strMessage = ex.Message
            Throw New Exception(strMessage)
        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