學習筆記
=============
模組中﹕
================
Public Type bapi_msg
mandt As Integer
cdate As Date
ctime As String
suname As String
tuname As String
msgtxt As String
ok As String
End Type
Public Type bapi_msg1
suname As String
tuname As String
msgtxt As String
End Type
=========================
表單中﹕
=========================
Private Sub btn_cnt_Click()'按扭事件
'Dim aa As bapi_msg
Dim bb As bapi_msg1
bb.suname = "aaa"
bb.tuname = "bb"
bb.msgtxt = "aaa to bb "
'創建物料﹐連接(登錄)SAP系統
Set function = CreateObject("SAP.LogonControl.1")
Set connection = Ofunction.newconnection
Oconnection.client = "800"
Oconnection.Language = "ZF"
Oconnection.user = "USERNAME"
Oconnection.password = "PASSWORD"
Oconnection.applicationserver = "192.168.**.**"
Oconnection.systemnumber = "00"
result = Oconnection.logon(0, True)
'指定所呼叫的函數(BAPI里的)
Set fun = CreateObject("SAP.FUNCTIONS")
Set Ofun.Connection = Oconnection
Set func = Ofun.Add("ZBAPI_VORTEX_SAVEMSG")
'給所呼叫的函數的參數賦值。此參數為structure類型。
func.exports("MSG1")("SUNAME") = bb.suname
func.exports("MSG1")("TUNAME") = bb.tuname
func.exports("MSG1")("MSGTXT") = bb.msgtxt
'提交
If func.call = True Then
MsgBox ("OK!")
Else
MsgBox ("Fail")
End If
'釋放
Oconnection.logoff
Set connection = Nothing
Set func = Nothing
End Sub
=============
模組中﹕
================
Public Type bapi_msg
mandt As Integer
cdate As Date
ctime As String
suname As String
tuname As String
msgtxt As String
ok As String
End Type
Public Type bapi_msg1
suname As String
tuname As String
msgtxt As String
End Type
=========================
表單中﹕
=========================
Private Sub btn_cnt_Click()'按扭事件
'Dim aa As bapi_msg
Dim bb As bapi_msg1
bb.suname = "aaa"
bb.tuname = "bb"
bb.msgtxt = "aaa to bb "
'創建物料﹐連接(登錄)SAP系統
Set function = CreateObject("SAP.LogonControl.1")
Set connection = Ofunction.newconnection
Oconnection.client = "800"
Oconnection.Language = "ZF"
Oconnection.user = "USERNAME"
Oconnection.password = "PASSWORD"
Oconnection.applicationserver = "192.168.**.**"
Oconnection.systemnumber = "00"
result = Oconnection.logon(0, True)
'指定所呼叫的函數(BAPI里的)
Set fun = CreateObject("SAP.FUNCTIONS")
Set Ofun.Connection = Oconnection
Set func = Ofun.Add("ZBAPI_VORTEX_SAVEMSG")
'給所呼叫的函數的參數賦值。此參數為structure類型。
func.exports("MSG1")("SUNAME") = bb.suname
func.exports("MSG1")("TUNAME") = bb.tuname
func.exports("MSG1")("MSGTXT") = bb.msgtxt
'提交
If func.call = True Then
MsgBox ("OK!")
Else
MsgBox ("Fail")
End If
'釋放
Oconnection.logoff
Set connection = Nothing
Set func = Nothing
End Sub
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14327814/viewspace-669685/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14327814/viewspace-669685/