Chinaunix首页 | 论坛 | 博客
  • 博客访问: 394321
  • 博文数量: 120
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 1266
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-16 16:04
文章分类

全部博文(120)

文章存档

2011年(4)

2010年(10)

2009年(38)

2008年(68)

我的朋友

分类:

2010-01-07 16:24:11

其实用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
阅读(1497) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~