‎2007 May 17 12:24 PM
Hello Guys,
I have to create a Purchase order with Visual Basic. I have created following code but at the end error is showing that <b>NO MASTER RECORD EXIST FOR VENDOR (VENDOR NO).</b>
but with the help of same data i am able to create PO in SAP. I have attach source code. Please take a look and provide me the valuiable information.
Option Explicit
Dim functionCtrl As Object
Dim sapConnection As Object
Dim theFunc As Object
Dim PoNumber
Private Sub Command1_Click()
Set functionCtrl = CreateObject("SAP.Functions")
Set sapConnection = functionCtrl.Connection
sapConnection.Client = "220"
sapConnection.User = "PTBITUSR"
sapConnection.Password = "HELLO2"
sapConnection.Language = "EN"
If sapConnection.Logon(0, False) <> True Then
MsgBox "No connection to R/3 System"
Exit Sub 'End program
End If
Set theFunc = functionCtrl.Add("BAPI_PO_CREATE")
Dim pocur As Object
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
Set poheader = theFunc.exports.Item("PO_HEADER")
Set poitems = theFunc.Tables.Item("PO_ITEMS")
Set poitemschedule = theFunc.Tables.Item("PO_ITEM_SCHEDULES")
Set pocur = theFunc.exports.Item("PO_HEADER_ADD_DATA")
poheader.Value("VENDOR") = "24001291" 'Text1.Text
poheader.Value("PUR_GROUP") = "PE6" '''Text3.Text
poheader.Value("DOC_TYPE") = "NB" ''Text4.Text
poitems.Rows.Add
poitems.Value(1, "PUR_MAT") = "SC101" ''Text5.Text
poitems.Value(1, "PLANT") = "1500" ''Text6.Text
poitems.Value(1, "NET_PRICE") = "2000" ''Text7.Text
poitemschedule.Rows.Add
poitemschedule.Value(1, "DELIV_DATE") = DTPicker1.Value
poitemschedule.Value(1, "QUANTITY") = 3 'Text9.Text
pocur.Value("CURRENCY") = "INR"
poheader.Value("PURCH_ORG") = "1500" '''Text2.Text
returnFunc = theFunc.call
PoNumber = theFunc.imports.Item("PURCHASEORDER")
Set retMess = theFunc.Tables.Item("RETURN")
If retMess Is Nothing Then
MsgBox retMess.Value(1, "MESSAGE")
Else
MsgBox retMess.Value(1, "MESSAGE")
MsgBox "Purchase Order No : " & PoNumber & "Created"
End If
End Sub
Regards
Swati Namdeo
‎2007 May 18 2:24 PM
in this case u have to pass complete data in full length.
<b>poheader.Value("VENDOR") = "0024001291" = 10 char length.</b>
Regards
Peram
‎2007 May 18 2:24 PM
in this case u have to pass complete data in full length.
<b>poheader.Value("VENDOR") = "0024001291" = 10 char length.</b>
Regards
Peram