VB访问 sap 

Dim functionCtrl As Object
Dim sapConnection As Object
Dim theFunc As Object
Dim PoNumber As String

Private Sub Command1_Click()

Set functionCtrl = CreateObject("SAP.Functions")
Set sapConnection = functionCtrl.Connection
sapConnection.System = "DEV"
sapConnection.ApplicationServer = "192.168.10.88"

sapConnection.Client = "400"
sapConnection.user = "ABAP03"
sapConnection.password = "123888"
sapConnection.Language = "EN"

If sapConnection.logon(0, False) = Ture Then
MsgBox "No connection to R/3 System"
Exit Sub 'End program
End If
Set theFunc = functionCtrl.Add("BAPI_PO_CREATE")


Dim poheader As Object
Dim poitems As Object
Dim poitemschedule As Object
Dim retMess As Object
Dim returnFunc As Boolean
Dim startzeil As Integer
Dim endcol As Integer
Dim the_name As String
Dim oCommit As Object

Set poheader = theFunc.exports.Item("PO_HEADER")
Set poitems = theFunc.tables.Item("PO_ITEMS")
Set poitemschedule = theFunc.tables.Item("PO_ITEM_SCHEDULES")

poheader.Value("VENDOR") = "0020000108"
poheader.Value("DOC_DATE") = "20081113"
poheader.Value("PURCH_ORG") = "1301"
poheader.Value("PUR_GROUP") = "003"
poheader.Value("CO_CODE") = "1300"
poheader.Value("DOC_TYPE") = "NB"

poitems.Rows.Add
poitems.Value(1, "PUR_MAT") = "000000001100005919"
poitems.Value(1, "PLANT") = "1301"
poitems.Value(1, "NET_PRICE") = "100"

poitems.Value(1, "TAX_CODE") = "J1"

poitemschedule.Rows.Add
poitemschedule.Value(1, "DELIV_DATE") = "20081120"
poitemschedule.Value(1, "QUANTITY") = "600"



returnFunc = theFunc.call
PoNumber = theFunc.imports("PURCHASEORDER")
Set retMess = theFunc.tables.Item("RETURN")
If retMess Is Nothing Then

MsgBox retMess.Value(1, "MESSAGE")
Else
MsgBox "Purchase Order No : " & PoNumber & "Created"
End If


End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值