|
Private Sub Command2_Click()
Dim theFunc As Object
Set sapFunctionCtrl = CreateObject("SAP.Functions")
Set sapConnection = sapFunctionCtrl.Connection
'sapConnection.ApplicationServer = "172.1.2.140"
sapConnection.Client = "000"
sapConnection.User = "ZYALL"
sapConnection.Password = "123123"
sapConnection.Language = "EN"
If sapConnection.Logon(0, False) <> True Then
MsgBox "No connection to R/3!"
End If
Set theFunc = sapFunctionCtrl.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
Dim PoNumber As String
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") = "0010000000"
poheader.Value("DOC_DATE") = "20081113"
poheader.Value("PURCH_ORG") = "Y990"
poheader.Value("PUR_GROUP") = "PG3"
poheader.Value("CO_CODE") = "C999"
'poheader.Value("DOC_TYPE") = "NB"
poitems.Rows.Add
poitems.Value(1, "PUR_MAT") = "F999-100"
poitems.Value(1, "PLANT") = "P990"
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"
If theFunc.call Then ' call the RFC FM
PoNumber = theFunc.Imports("PURCHASEORDER")
'MsgBox "RFC call is okay"
Me.Text1.Text = PoNumber
' Next i
Else
MsgBox " 搜索出错! 出错信息: " + theFunc.Exception
End
End If
SAPHE 帮看一下,哪错了????
'poheader.Value("DOC_TYPE") = "NB" 这个值对应的是哪个字段???? |
|