eConnect - POPTransactionType, taPOLine, taPOHdr

This is a complete code example for creating a PO. The example uses a class as the data source; we're not going to document that because it changes every client. The point is to have a set of code that we can copy into an application and edit rapidly

All our eConnect code uses the common functions class

 

    Sub CreatePurchaseOrder(ByVal dataSetClaim As DataSetClaim)
        Try
            Dim strServer As String = System.Configuration.ConfigurationManager.AppSettings("SQLServer")
            Dim strDatabase As String = System.Configuration.ConfigurationManager.AppSettings("Database")
 
            For Each purchaseOrder As purchaseOrder In dataSetClaim.purchaseOrder
                Dim strPONumber As String = purchaseOrder.PONumber
                Dim strVendorID As String = getVendor(purchaseOrder.ManufactID)
                'declare our eConnect classes
                Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
                Dim oPOPTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.POPTransactionType
                Dim oeConnectFunctions As New eConnectFunctions(strServer, strDatabase)
 
                'create the document header
                Dim otaPoHdr As New Microsoft.Dynamics.GP.eConnect.Serialization.taPoHdr
 
                'populate the header
                With otaPoHdr
                    .PONUMBER = strPONumber
                    .VENDORID = strVendorID
                    .DOCDATE = Now.ToShortDateString
                    .ALLOWSOCMTS = 1
                    .ALLOWSOCMTSSpecified = 1
                    .VADCDPAD = "" ' vendor address code
                    .UpdateIfExists = 1
                End With
 
                'assign the header to the master
                oPOPTransactionType.taPoHdr = otaPoHdr
 
                Dim intCurrentLine As Int16 = 0
 
                For Each poi As purchaseOrderItem In dataSetClaim.purchaseOrderItem
                    If poi.PurchaseOrderID <> purchaseOrder.PurchaseOrderID Then
                        Continue For
                    End If
 
 
                    'declare an object for the detail line
                    Dim otaPoLine As New Microsoft.Dynamics.GP.eConnect.Serialization.taPoLine_ItemsTaPoLine
 
                    'populate the detail line
                    With otaPoLine
                        LineItemIDToFind = poi.LineItemID
                        Dim li As lineItem = dataSetClaim.lineItem.Find(AddressOf findItemByID)
                        .PONUMBER = strPONumber
                        .VENDORID = strVendorID
                        .ITEMNMBR = li.ItemNumber
                        .LOCNCODE = dataSetClaim.LocationCode
                        .VNDITNUM = li.ItemNumber
                        .QUANTITY = poi.QuantityOrdered
                        .QUANTITYSpecified = 1
                        .ITEMDESC = li.ItemDescription
                        .UNITCOST = poi.Cost
                        .UNITCOSTSpecified = 1
                        .UOFM = "EA"
                        .USRDEFND2 = li.LineItemSequence
                        .USRDEFND1 = li.SOPNumber
 
                    End With
 
                    ReDim Preserve oPOPTransactionType.taPoLine_Items(intCurrentLine)
                    oPOPTransactionType.taPoLine_Items(intCurrentLine) = otaPoLine
 
                    intCurrentLine += 1
                Next 'PO Line
 
 
                ReDim Preserve oeConnectType.POPTransactionType(0)
                oeConnectType.POPTransactionType(0) = oPOPTransactionType
                oeConnectFunctions.CreateTransactionEntity(oeConnectType)
            Next 'PO
 
 
        Catch ex As Exception
            Throw ex
        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