2010 Mar 04 12:02 PM
Hi All,
I am facing problem in BAPI when I am creating object in MS Access 2007. error message is "Run time Error 424" Object required.
Login to SAP via Access is successfull but it is not creating object of "SalesOrder".
Kindly help in this regards,
Please see the MS access coding.
Dim x As Object
Dim boOrder As Object
Dim oPartner As Object
Dim oItemin As Object
Dim oheader As Object
' scuccessfully login to SAP
If oBAPICtrl.Connection.Logon(0, False) <> True Then
MsgBox "connection failed"
Else
MsgBox "connection successfull"
End If
'(Generate runtime error)in below line*
Set boOrder = bapictrl.GetSAPObject("SalesOrder")
Syed Tayab Shah
Edited by: syed Tayab Shah on Mar 4, 2010 5:03 PM
2010 Mar 04 12:19 PM
I don't have any hands on experience in calling BAPI from MS Access, but when I look at the error, it looks like a short dump in the SAP System. Logon to the SAP system en check transaction ST22 for short dumps.
2010 Mar 04 12:23 PM
Thanks Micky for your reply.
I had checked it but no error found in ST22.
Regards,
Syed Tayab Shah
2010 Mar 05 6:35 AM
2010 Mar 08 7:48 AM
I had tried successfully, but when BAPI is executed then no effect in R/3 system.
Code is
Dim x As Object
Dim boOrder As Object
Dim Obname As Object
Dim oPartner As Object
If oBAPICtrl.Connection.Logon(0, False) <> True Then
MsgBox "connection failed"
Else
MsgBox "connection successfull"
End If
Set Obname = oBAPICtrl.GetSAPObject("InternalOrder")
Set oPartner = oBAPICtrl.DimAs(Obname, "Create", "I_Master_Data")
oPartner.Value("ORDER") = "ext-10-20004"
oPartner.Value("ORDER_NAME") = "test IO for BAPI 4"
oPartner.Value("ORDER_TYPE") = "ZEPJ"
oPartner.Value("CO_AREA") = "CYBR"
oPartner.Value("COMP_CODE") = "CYBR"
oPartner.Value("CURRENCY") = "PKR"
oBAPICtrl.Connection.Logoff
Set sapConnection = Nothing
This internal order does not exist after BAPI execute.
Regards,
Syed Tayab Shah
2010 Mar 08 8:50 AM
Normally, every BAPI call has to be commited to the database using BAPI_TRANSACTION_COMMIT. Maybe this is missing in your case. BTW: Only do a commit when no error returned from BAPI call.
2010 Mar 10 1:47 PM
Hi All,
Here is following codes that I am using in MS ACCESS 2007, its running without any error but there no PO in SAP R3 system.
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 = "400"
sapConnection.User = "ABAPDEV"
sapConnection.Password = "cyber777"
sapConnection.System = "202.163.96.164"
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 poheader As Object
Dim poitems As Object
Dim poitemschedule As Object
Dim PoitemAccountAssignm As Object
Dim retMess As Object
Dim Skip_Items_With_Error 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 Skip_Items_With_Error = theFunc.exports.Item("SKIP_ITEMS_WITH_ERROR")
Set poitems = theFunc.tables.Item("PO_ITEMS")
Set poitemschedule = theFunc.tables.Item("PO_ITEM_SCHEDULES")
Set PoitemAccountAssignm = theFunc.tables.Item("POITEMACCOUNTASSIGNM")
'Skip_Items_With_Error.Value = "X"
poheader.Value("DOC_TYPE") = "NB"
poheader.Value("VENDOR") = "11000"
poheader.Value("PURCH_ORG") = "1000"
poheader.Value("PUR_GROUP") = "001"
poitems.Rows.Add
poitems.Value(1, "PUR_MAT") = "279"
poitems.Value(1, "PLANT") = "1000"
poitems.Value(1, "NET_PRICE") = "8000"
'poitems.Value(1, "QUANTITY") = 10
poitemschedule.Rows.Add
poitemschedule.Value(1, "DELIV_DATE") = CDate("18/03/2010")
poitemschedule.Value(1, "QUANTITY") = "10"
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
Set theFunc = functionCtrl.Add("BAPI_TRANSACTION_COMMIT")
End Sub
Can any body tell about the this.
Regards,
Syed Tayab Shah