eConnect - Transaction Requester - Get one SOP line

In a recent project, we needed to

  • Get a line from a SOP document
  • Delete the line
  • Resubmit the line using the SOPTransactionType. (It allows you to submit a line only, and that will add a line to the SOP document)

This is the piece of code that we used to do step one, getting the SOP document line.

This function takes a SOP Number, Type, and Line Item Sequence as params and returns a 

Microsoft.Dynamics.GP.eConnect.Serialization.taSopLineIvcInsert_ItemsTaSopLineIvcInsert

 object. Since it's already in that form all we have to do is to edit it a little and re-submit it.

    Function getSopLine(SOPNUMBE As String, SOPTYPE As Int16, LNITMSEQ As Int32As Microsoft.Dynamics.GP.eConnect.Serialization.taSopLineIvcInsert_ItemsTaSopLineIvcInsert
        'initialize our eConnect wrapper class, documented here:
        'http://dyndeveloper.com/thread.aspx?Threadid=1117
        Dim oeConnectFunctions As New eConnect11Lib.GP11.eConnectFunctions("localhost""two")
        Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
        Dim oSOPTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.SOPTransactionType
 
 
        'get an XML document that represents the customer 
        'this uses our SalesTransactionRetrieve class documented here
        'http://dyndeveloper.com/articleview.aspx?ArticleID=173
        Dim oSalesTransactionRetrieve As New SalesTransactionRetrieve
        Dim strSOPTrans As String = oSalesTransactionRetrieve.SalesTransactionRetrieve(SOPNUMBE, SOPTYPE)
 
 
        '==========================================================
        'parse the line
        '==========================================================
        'strSOPTrans is an XML document in string form
        'parse it into XDocument form
        Dim doc = XDocument.Parse(strSOPTrans)
 
        'use Linq-to-XML to select just one sop line in the document. 
        Dim query = _
            From c In doc.<root>.<eConnect>.<SO_Trans>.<Line> _
            Where c.<LNITMSEQ>.Value = LNITMSEQ _
            Select c
 
        'turn it back into a string so we can edit it a little
        Dim strXMLSegment As String = query.First.ToString
 
        'change 'Line' into 'taSopLineIvcInsert_ItemsTaSopLineIvcInsert'
        strXMLSegment = Replace(strXMLSegment, "Line""taSopLineIvcInsert_ItemsTaSopLineIvcInsert")
        'Use a StringReader to read the XML for the XML node
        Dim myReader As New StringReader(strXMLSegment)
 
        'Deserialize the XML node from the StringReader into the taSopLineIvcInsert_ItemsTaSopLineIvcInsert object.
        Dim oXmlSerializer As New XmlSerializer(GetType(taSopLineIvcInsert_ItemsTaSopLineIvcInsert))
        'Cast the deserialized object to a taSopHdrIvcInsert serialization object
        Dim otaSopLineIvcInsert As taSopLineIvcInsert_ItemsTaSopLineIvcInsert = CType(oXmlSerializer.Deserialize(myReader), taSopLineIvcInsert_ItemsTaSopLineIvcInsert)
        Return otaSopLineIvcInsert
 
    End Function

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