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
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