请教如何使用LCConnection.Call
深圳陈建军 2006-04-11 09:37:58 使用Lotus Connector for SAP进行Lotus Script的开发,参考帮助我写了一个代理,代理调用一个SAP的BAPI,传递一个参数到该BAPI,其返回一个值,但在执行LCConnection.Call时,总是被提示“Field mapping failed due to a missing field, Connector 'sap', Method -Call-”
代理代码如下:
Sub testconnect
On Error Goto errorhandler
Dim mastersession As New LCSession
Dim sapsession As New LCConnection("sap")
sapsession.Userid = "abc"
sapsession.Password = "123456"
sapsession.Client= "400"
sapsession.Destination= "192.168.1.1"
sapsession.SystemNo= Val(02)
sapsession.Language= "E"
sapsession.Server= "192.168.1.1"
Call sapsession.Connect()
Msgbox "connect success!"
Dim reqinputlist As New LCFieldList
Dim reqoutputlist As New LCFieldList
sapsession.Database="Z_BAPI_TEST01"
sapsession.Metadata="*"
sapsession.Mapbyname=True
Dim field As LCField
Set field = reqinputlist.Append("P_INPUT",LCTYPE_INT)
Call field.SetInt(1,1)
found = sapsession.Call(reqinputlist,1,reqoutputlist)
If found Then
'do something
End If
Exit Sub
errorhandler:
Dim Msg As String
Dim Msgcode As Long
Dim status As Integer
Dim result As String
If mastersession.status <> LCSUCCESS Then
status = mastersession.GetStatus(result, Msgcode, Msg)
End If
Msgbox result
Msgbox "line:"+Str(Erl())+" error:[" +Str(Err)+ "] " + Error
End Sub
帮助中对该错误的解释是:
&H3108 12552 LCFAIL_MERGE_FIELD Field mapping failed due to a missing field [‘FIELDNAME’]
When using the methods LCFieldlist.Merge or MergeVirtual, there was a mismatch between the fieldlists. Either a field in the namelist had no match in the data list, or vice-versa. If such a mismatch occurs and the merge flag LCMERGEF_NAME_LOSS or LCMERGEF_DATA_LOSS is not specified to indicate that loss of fields is allowed, then this error is generated. Ensure that the field indicated in the error has a corresponding field in the other fieldlist.
根据这段解释,大概是说LCConection.Call()方法中的两个LCFieldList参数,其中一个的Field Name和Field Data的个数(或数据类型)不一致(?)。我可以确定在调用的BAPI中的参数个数和类型都和我定义是一样的,但还是出错。我把sapsession.Call(reqinputlist,1,reqoutputlist)改成sapsession.Call(reqinputlist,1,Nothing)也报同样的错。到底是什么问题呢?有没有用过LC LSX for SAP的朋友给解释一下。或者有经验的朋友提供一些调式思路。谢谢了!