e Connect – SOP Hold – VB.net example

Click on the script  and use left and right arrow keys to scroll horizontally.

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class sophold
    'Update values for below variales 
    Dim _sopnumber = "SOP Document number"
    Dim _sopholdid = "SOP HOLD ID"
    Dim _sopholdpw = "SOP hOLD PW"
    Dim _SQLConnectionString = "data source=[SQLSERVER];initial catalog=[COMPANY DB];integrated security=SSPI; persist security info=False;packet size=4096"

    'Call this function to place a hold.
    Public Sub eConnectSend()
        'Serialized XML File         
        Dim xmldocument As String
        'Connection String         
        Dim sConnectionString As String
        'Result         
        Dim xmlobject As String
        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml ", _sopnumber, _sopholdid, _sopholdpw)
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = _SQLConnectionString
                xmlobject = eConCall.CreateTransactionEntity(sConnectionString, xmldocument)
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String, sopnumber As String, sopholdid As String, sopholdpw As String)
        Try
            Dim econnect As New eConnectType
            Dim Holdtype As New SOPProcessHoldType
            Dim holdrecord As New taSopUpdateCreateProcessHold
            With holdrecord
                'Check xml element reference at below table
                .SOPTYPE = 2
                .SOPNUMBE = sopnumber
                .PRCHLDID = sopholdid
                .PASSWORD = sopholdpw
                .DELETE1 = 0 
            End With
            Holdtype.taSopUpdateCreateProcessHold = holdrecord
            ReDim Preserve econnect.SOPProcessHoldType(0)
            econnect.SOPProcessHoldType(0) = Holdtype
            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, econnect)
            writer.Close()
        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation. THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

XML Node taSopUpdateCreateProcessHold element reference extracted from eConnect Programmers reference Guide for immediate reference.
Element name Data type Length Required Description
SOPTYPE i4 2 Y 1=Quote;
2=Order;
3=Invoice;
4=Return;
5=Back order;
6=Fulfillment order
SOPNUMBE string 21 Y Invoice number
PRCHLDID string 15 Y Process hold ID
DSCRIPTN string 30 N Process hold description
PASSWORD string 15 N Process hold password
XFERPHOL i4 1 N Transferring process hold
POSTPHOL i4 1 N Posting process hold
FUFIPHOL i4 1 N Fulfill process hold
PRINPHOL i4 1 N Printing process hold
HOLDDATE datetime 16 N Hold date
USERID string 15 N User ID
TIME1 datetime 16 N Hold time
DELETE1 i4 4 N 0=Add process hold,
1=Remove process hold
UpdateIfExistsMaster i4 4 N Update process hold master information, if it exists in the parameters
UpdateSopIfExists i4 4 N Update SOP record if it exists

Serialized XML File Generated:

<?xml version="1.0" ?>
<eConnect xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOPProcessHoldType>
    <eConnectProcessInfo xsi:nil="true"/>
    <taRequesterTrxDisabler_Items xsi:nil="true"/>
    <taSopUpdateCreateProcessHold>
      <SOPTYPE>
        2
      </SOPTYPE>
      <SOPNUMBE>
        ORD0075165
      </SOPNUMBE>
      <PRCHLDID>
        APPROVE
      </PRCHLDID>
      <PASSWORD>
        safe
      </PASSWORD>
    </taSopUpdateCreateProcessHold>
  </SOPProcessHoldType>
</eConnect>

Cheers!
Sanjay

GP Constants

GP Constants - Sales Order Processing

FieldConstantValue
SOPTYPE1Quote
SOPTYPE2Order
SOPTYPE3Invoice
SOPTYPE4Return
SOPTYPE5Back Order
SOPTYPE6Fulfillment Order
PYMTTYPE1Cash Deposit
PYMTTYPE2Check Deposit
PYMTTYPE3Credit Card Deposit
PYMTTYPE4Cash Payment
PYMTTYPE5Check Payment
PYMTTYPE6Credit Card Payment
DISTTYPE1SALES
DISTTYPE2RECV
DISTTYPE3CASH
DISTTYPE4TAKEN
DISTTYPE5AVAIL
DISTTYPE6TRADE
DISTTYPE7FREIGHT
DISTTYPE8MISC
DISTTYPE9TAXES
DISTTYPE10MARK
DISTTYPE11COMMEXP
DISTTYPE12COMMPAY
DISTTYPE13OTHER
DISTTYPE14COGS
DISTTYPE15INV
DISTTYPE16RETURN
DISTTYPE17IN USE
DISTTYPE18IN SERVICE
DISTTYPE19DAMAGED
DISTTYPE20UNIT
DISTTYPE21DEPOSITS
DISTTYPE22ROUND
DISTTYPE23REBATE
PURCHSTAT1None
PURCHSTAT2Needs Purchase
PURCHSTAT3Purchased
PURCHSTAT4Partially Received
PURCHSTAT5Fully received
QTYTYPE1On Hand
QTYTYPE2Returned
QTYTYPE3In Use
QTYTYPE4In Service
QTYTYPE5Damaged
PROSPECT0Existing Customer
PROSPECT1Prospect
COMAPPTO0Sales
COMAPPTO1Invoice Total
VOIDSTTS0Not Voided
VOIDSTTS1Voided
DROPSHIP0Not Drop Ship
DROPSHIP1Drop Ship
NONINVEN0Inventoried item
NONINVEN1Not Inventoried
SOPSTATUS1New
SOPSTATUS2Ready to Print Pick Ticket
SOPSTATUS3Unconfirmed Pick
SOPSTATUS4Ready to Print Packing Slip
SOPSTATUS5Unfonfirmed Pack
SOPSTATUS6Shipped
SOPSTATUS7Ready to Post
SOPSTATUS8In Process
SOPSTATUS9Complete
DELETE10Not deleted
DELETE11Hold removed
PSTGSTUS0Not Posted
PSTGSTUS2Posted
PSTGSTUS3Error
PSTGSTUS508Transferring to History