ITPub博客

首页 > Linux操作系统 > Linux操作系统 > VBA call sap-BAPI's function

VBA call sap-BAPI's function

原创 Linux操作系统 作者:moomwy 时间:2010-07-28 11:43:13 0 删除 编辑
學習筆記
=============
模組中﹕
================

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博客 ” ,链接:https://blog.itpub.net/14327814/viewspace-669685/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: (OLE)Excel.Application
请登录后发表评论 登录
全部评论

注册时间:2009-01-14

  • 博文量
    2
  • 访问量
    3824