其实用BAPI_DOCUMENT_CHECKOUTVIEW2是可以的,只是有个参数(红色部分)我没设置,才导致问题。
Function SAPCheckinExample()
Dim R3 As Object
Dim conn As Object
Dim rfcFunc As Object
Dim PF_DOKAR As Object, PF_DOKNR As Object
Dim PF_DOKTL As Object, PF_DOKVR As Object
Dim PSX_MESSAGE As Object, PT_FILES_X As Object
Dim PF_FTP_DEST As Object
Dim PF_HTTP_DEST As Object
Dim PATH As Object
Dim blnResult As Boolean
'**** Change these constants as desired ****************
Const strDocTyp As String = "ST4"
Const strDocNum As String = "TCD00000000492"
Const strDocPrt As String = "000"
Const strDocVer As String = "-"
'**** Program extract **********************************
' Create a new connection object
Set R3 = CreateObject("SAP.Functions.unicode")
Set conn = R3.Connection
' Set the logon parameters
conn.ApplicationServer = "***"
conn.Client = "***"
conn.User = "***"
conn.Password = "***"
conn.Language = "ZH"
conn.AutoLogon = True
conn.rfcwithdialog = "1"
' Logon
If conn.Logon(0, True) = True Then
' Create the checkin rfc in the connection object
Set rfcFunc = R3.Add("BAPI_DOCUMENT_CHECKOUTVIEW2")
' Link the parameters from the rfc to the objects
' called in this function
With rfcFunc
Set PF_DOKAR = .exports("DOCUMENTTYPE")
Set PF_DOKNR = .exports("DOCUMENTNUMBER")
Set PF_DOKTL = .exports("DOCUMENTPART")
Set PF_DOKVR = .exports("DOCUMENTVERSION")
Set PATH = .exports("ORIGINALPATH")
Set PF_FTP_DEST = .exports("PF_FTP_DEST")
Set PF_HTTP_DEST = .exports("PF_HTTP_DEST")
Set PSX_MESSAGE = .Imports("RETURN")
Set PT_FILES_X = .Tables("DOCUMENTFILES")
End With
' Set the parameters for the rfc
PF_DOKAR.Value = strDocTyp ' Document Type
PF_DOKNR.Value = strDocNum ' Document number
PF_DOKTL.Value = strDocPrt ' Document Part
PF_DOKVR.Value = strDocVer ' Document Version
PF_FTP_DEST.Value = "SAPFTP"
PF_HTTP_DEST.Value = "SAPHTTP"
PATH.Value = "C:\"
' Call the rfc
blnResult = rfcFunc.Call
'Check if the rfc is executed correctly
Set PSX_MESSAGE = rfcFunc.Imports("PSX_MESSAGE")
MsgBox PSX_MESSAGE("TYPE") & "_" & PSX_MESSAGE("ID") & "_" & PSX_MESSAGE("NUMBER") & "_" & PSX_MESSAGE("MESSAGE")
conn.Logoff
End If
End Function
阅读(1532) | 评论(0) | 转发(0) |