|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
本人试着调用库存API完成增加采购入库单,但不知怎么样回事,在最后INVOKEAPI时,却一直提示:“对象引用未设置到对象的实例。”我检查了个参数,尤其是对象,他们都已经被实例化了。请各位高手帮忙看一下,这个项目耽误了很长时间了,老板催得很急。以下是项目的代码。生成API部分基本上完全仿照例程来做的。
以下是代码。
Private Sub Command3_Click()
'GrdDispLis是一个MSFLEXGRID,为一个数据列表,是采购入库单的数据来源。
Dim U8EnvCtx As New U8EnvContext
Dim U8ApiBroker As New U8ApiComBroker
Dim cDlCode, sDate, cWhCode, cWhName, cInvCode, cMaker, cAuditor As String
Dim nRdId, nRdAutoId As Long
Dim DomHead, DomBody As New BusinessObject
Dim domMsg As MSXML2.IXMLDOMDocument2
Dim bSucess As Boolean
Dim domPosition As Object
bSucess = True
Set domMsg = New MSXML2.DOMDocument
Dim oConn As New ADODB.Connection
InitRes
Login
GrdDispList.Row = GrdDispList.RowSel
GrdDispList.Col = 2
sDate = GrdDispList.Text
GrdDispList.Col = 5
cWhCode = GrdDispList.Text
GrdDispList.Col = 21
cMaker = GrdDispList.Text
GrdDispList.Col = 22
cMaker = GrdDispList.Text
nAutoId = CalcRdAutoId()
Set U8EnvCtx.U8Login = g_oLogin
U8ApiBroker.Connect "U8API/PuStoreIn/Add", U8EnvCtx
U8ApiBroker.AssignNormalValue "sVouchType", "01"
Set DomHead = U8ApiBroker.GetBoParam("DomHead")
Set DomBody = U8ApiBroker.GetBoParam("DomBody")
DomHead.RowCount = 1
cDlCode = GeneralRdCode()
nRdId = CalcRdId()
DomHead(0).SetValue "bOmFirst", "False"
DomHead(0).SetValue "ccode", cDlCode
DomHead(0).SetValue "ID", nRdId
DomHead(0).SetValue "ddate", sDate
DomHead(0).SetValue "iverifystate", 0
DomHead(0).SetValue "cvouchtype", "01"
DomHead(0).SetValue "iswfcontrolled", 0
DomHead(0).SetValue "cvencode", "002"
DomHead(0).SetValue "cvenabbname", "001"
DomHead(0).SetValue "cbustype", "普通采购"
DomHead(0).SetValue "cmaker", cMaker
DomHead(0).SetValue "iexchrate", 0
DomHead(0).SetValue "cexch_name", "人民币"
' DomHead(0).SetValue "utfs", "0"
DomHead(0).SetValue "bpufirst", False
DomHead(0).SetValue "cWhCode", cWhCode
DomHead(0).SetValue "brdflag", "0"
DomHead(0).SetValue "csource", "库存"
DomBody.RowCount = 1
DomBody(0).SetValue "autoid", nAutoId
DomBody(0).SetValue "id", nRdId
DomBody(0).SetValue "cinvcode", cInvCode
DomBody(0).SetValue "editprop", "A"
DomBody(0).SetValue "autoid", nAutoId
DomBody(0).SetValue "iQuantity", 1
DomBody(0).SetValue "iMatSettleState", 0
U8ApiBroker.AssignNormalValue "domPosition", domPosition
U8ApiBroker.AssignNormalValue "cnnFrom", oConn
U8ApiBroker.AssignNormalValue "domMsg", domMsg
U8ApiBroker.AssignNormalValue "bCheck", False
U8ApiBroker.AssignNormalValue "bBeforCheckStock", False
U8ApiBroker.AssignNormalValue "bIsRedVouch", False
' bSucess = U8ApiBroker.InvokeApi()
If U8ApiBroker.InvokeApi() = False Then
MsgBox U8ApiBroker.GetLastError(), vbCritical
Else
errMsgRet = CStr(U8ApiBroker.GetResult("errMsg"))
VouchIdRet = CStr(U8ApiBroker.GetResult("VouchId"))
End If
U8ApiBroker.Disconnect
Set U8ApiBroker = Nothing
End Sub
|
|