Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect vb6.0 through BAPI. Its given error code 8792?

Former Member
0 Kudos

when i m going to connect Bapi in vb 6.0 its showing error like

Dim boorder As Object

Set boorder = *bapictrl.getsapobject*("SalesOrder")

run time error '8792'.

error key: RFC_ERROR_SYSTEM_FAILURE

in vb 6.0

4 REPLIES 4

Former Member
0 Kudos

U can use code in VB like below.

Option Explicit

Dim functionCtrl As Object

Dim sapConnection As Object

Dim theFunc As Object

Dim retMess As Object

Dim returnFunc As Boolean

Private Sub Form_Load()

matnr.Text = "000000000000000023"

End Sub

Private Sub Logon_Click()

Set functionCtrl = CreateObject("SAP.Functions")

Set sapConnection = functionCtrl.Connection

'sapConnection.client = "650"

'sapConnection.user = "ABAP2"

sapConnection.password = "ABAP2"

'sapConnection.Language = "EN"

If sapConnection.Logon(0, False) <> True Then

MsgBox "No connection to R/3 System"

Exit Sub 'End program

Else

'MsgBox "Connection Made"

Logon.Caption = "Logged"

End If

End Sub

Private Sub proceed_click()

Set theFunc = functionCtrl.Add("ZBAPINEW")

theFunc.exports("MATNR") = matnr.Text '

returnFunc = theFunc.call

maktx.Text = theFunc.imports("MAKTX")

MAKTG.Text = theFunc.imports("MAKTG")

End Sub

Private Sub EXIT_Click()

Unload Me

End Sub

Former Member
0 Kudos

Hi Rajesh,

Good Mor......

This line

If sapConnection.Logon(0, False) True Then

its given the syntax error i correct this statment

If sapConnection.Logon(0, False) = True Then

but agin its showing No connection to R/3 System connection not established

Edited by: Annasaheb More on Sep 11, 2008 7:37 AM

Former Member
0 Kudos

Hi,

Go Through the Follwing Code:

INCLUDE BAPI OBJECT FROM REFRENCES FIRST.

Code

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 = "500"

sapConnection.user = "USERNAME"

sapConnection.password = "PASSWORD"

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

poheader.Value("VENDOR") = Text1.Text

poheader.Value("PURCH_ORG") = Text2.Text

poheader.Value("PUR_GROUP") = Text3.Text

poheader.Value("DOC_TYPE") = Text4.Text

poitems.Rows.Add

poitems.Value(1, "PUR_MAT") = Text5.Text

poitems.Value(1, "PLANT") = Text6.Text

poitems.Value(1, "NET_PRICE") = Text7.Text

poitemschedule.Rows.Add

poitemschedule.Value(1, "DELIV_DATE") = Text8.Text

poitemschedule.Value(1, "QUANTITY") = Text9.Text

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

Hope it will solve your problem.

Thanks

Rajesh Kumar

Former Member
0 Kudos

Hi Rajesh

i am using sap r/3 6.00 ecc

and agin in vb code this statement given syntex erro

If sapConnection.logon(0, False) True Then

if i rectify

If sapConnection.logon(0, False) = True Then

it show the No connection to R/3 System

pls reply.........

Thanks

Annasaheb

Edited by: Annasaheb More on Sep 11, 2008 7:37 AM