Hello all. I'm a newbie and hoping for a little help. Using the e-connect examples I've got this far and cannot get any further. i'm simply trying to piece together a simple PO import. We're on GP 2013 R2 using .NET C#. I think the issue is adding the line to the PO, but i'm not certain. ANY and ALL help is much appreciated!!!! here is our code:
_______________________________________________________________________
Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Module Module1
Sub Main()
'String variable to hold the xml document
Dim sCustomerDocument As String
'String variable to hold the SQL connection string
Dim sConnectionString As String
'Use the eConnect methods to send the xml document to GP
Using e As New eConnectMethods
'Begin error trapping
Try
'Run the SerializeCustomerObject sub (see below) to create the XML document called Customer.xml
SerializeCustomerObject("Customer.xml")
'Load the customer XML document into an XML document object
Dim xmldoc As New Xml.XmlDocument
xmldoc.Load("Customer.xml")
'Use the XML Document to create a string
sCustomerDocument = xmldoc.OuterXml
'Create a connection string to your Microsoft Dynamics GP Datebase
'Replace data source and inital catalog values to use your server and company database
sConnectionString = "data source=GP-2013;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096"
'From the eConnect namespace. the CreateEntity function creates the new customer in Microsoft Dynamics GP.
e.CreateEntity(sConnectionString, sCustomerDocument)
'Catch any errors
Catch exc As eConnectException
Console.Write("An eConnect error occured")
Console.Write(exc.ToString)
Catch ex As System.Exception
Console.Write(ex.ToString)
Finally
'Use the dispose method to release the resources of
'eConnectMethods object
e.Dispose()
End Try
End Using
End Sub
Public Sub SerializeCustomerObject(ByVal filename As String)
'This sub routine utilizes the eConnect.Serialization namespace to create the xml document
'Use the System.XML class which will serialize the xml document
Dim serializer As New XmlSerializer(GetType(eConnectType))
'From the eConnect.Serialization Namespace. The eConnectType class represents the root of the eConnect document and holds
'different eConnect document collection objects.
Dim eConnect As New eConnectType
'From the eConnect.Serialization Namespace. The taUpdateCreateCustomerRcd class represents the eConnect node used to update or create customers.
Dim otaPoHdr As New taPoHdr
'From the eConnect.Serialization Namespace. the RMCustomerMaterType contains the schema representing the CustomerMaster Document colleciton.
Dim oPOPTransactionType As New POPTransactionType
'Begin error trapping.
Try
'Populate the taPopRcptHdrInsert XML node with customer data
With otaPoHdr
'.POTYPE = 1
.PONUMBER = "PO3333"
.VENDORID = "FABRIKAM0001"
.DOCDATE = "04152017"
.ALLOWSOCMTS = 1
.ALLOWSOCMTSSpecified = 1
.VADCDPAD = "PRIMARY"
.UpdateIfExists = 1
'.CURNCYID = "Z-US$"
.TAXSCHID = "COMPANYPUR"
End With
'assign the header to the master
oPOPTransactionType.taPoHdr = otaPoHdr
Dim intCurrentLine As Int16 = 0
'declare an object for the detail line
Dim otaPoline As New taPoLine_ItemsTaPoLine
With otaPoline
.PONUMBER = "PO3333"
.VENDORID = "FABRIKAM0001"
.ITEMNMBR = "3-A2440A"
.LOCNCODE = "131G"
.VNDITNUM = "131G"
.QUANTITY = "3.000"
.QUANTITYSpecified = 1
.ITEMDESC = "tst"
.UNITCOST = "100.00"
.UNITCOSTSpecified = 1
.UOFM = "EA"
'.QTYCANCE = "0.000"
End With
'Populate the RMCustomerMasterType schema with the taUpdateCreateCustomerRcd XML node object
'oPOPTransactionType.taPoHdr = otaPoHdr
ReDim Preserve oPOPTransactionType.taPoLine_Items(intCurrentLine)
oPOPTransactionType.taPoLine_Items(intCurrentLine) = otaPoline
intCurrentLine += 1
'Populate the eConnect XML document object with the RMCustomerMasterType schema object
ReDim Preserve eConnect.POPTransactionType(0)
eConnect.POPTransactionType(0) = oPOPTransactionType
'Next
'Create file and XML writer objects to serialize the eConnect XML document.
Dim fs As New FileStream(filename, FileMode.Create)
Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
'Use the XmlTextWriter to serializer the eConnect XML document object to the file
serializer.Serialize(writer, eConnect)
writer.Close()
Catch ex As System.ApplicationException
Console.Write("Error occured while creating the customer XML document and file")
Console.Write(ex.ToString)
End Try
End Sub
End Module
__________________________________________________________________________
*This post is locked for comments