Application Development and Automation 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: 
Read only

Loading data with BAPI via VB.NET

Former Member
1,878

Hello experts,

I am attempting to put a vb.net project together to load data for material master via BAPI. I am having some difficulty doing so using my only reference u201CVisual Basic SAP R/3 Programmingu201D by Oleg Ovanesyan. I believe it was released in the late 90u2019s. Do you know of any other references that will walk a person through using the SAP Active X controls that come with SAP GUI for vb.net? I am using Visual Studio 2008 or 2010 by the way.

Is downloading the SAP .Net Connector from the SAP site the only answer? If so, is there a place I can get this without being a Partner or Customer. I am currently renting access to a SAP system for my development.

Thank you all for the help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
937

Hi Michael,

I have created a Macro in excel to call a BAPI in SAP. You can modify the code where required.

Excel uses VBA so the code should be practically the same



'Connect to a SAP system
'Connection object
Dim sapConnection As Object

'Function Control (Collective object)
Dim objBAPIControl As Object

Set objBAPIControl = CreateObject("SAP.Functions")
Set sapConnection = objBAPIControl.Connection

'Get these details from the SAP GUI
sapConnection.ApplicationServer = "AppServer"
sapConnection.HostName = "HostName"
sapConnection.SystemNumber = "00"
sapConnection.System = "000"
sapConnection.Client = "300"
sapConnection.User = "DSOUZA"
sapConnection.Password = "Password"
sapConnection.Language = "EN"


If sapConnection.logon(0, False) Then

	perform check_user(objBAPIControl)

Else
  MsgBox "Could not connect to SAP system".
End If

'Call the BAPI from the SAP system
public sub check_user(objBAPIControl As Object)

Dim objUserBapi As Object
Set objUserBapi = objBAPIControl.Add("BAPI_USER_EXISTENCE_CHECK")

'Input parameters of BAPI
objUserBapi.exports("USERNAME").Value = "TestUser"

If objJobList.Call Then
	dim return as object

'Export parameters of BAPI
	set return = objUserBapi.imports("RETURN")
	msgbox return.value("MESSAGE")

else
 msgbox "Could not execute BAPI".
end if

5 REPLIES 5
Read only

Former Member
0 Likes
938

Hi Michael,

I have created a Macro in excel to call a BAPI in SAP. You can modify the code where required.

Excel uses VBA so the code should be practically the same



'Connect to a SAP system
'Connection object
Dim sapConnection As Object

'Function Control (Collective object)
Dim objBAPIControl As Object

Set objBAPIControl = CreateObject("SAP.Functions")
Set sapConnection = objBAPIControl.Connection

'Get these details from the SAP GUI
sapConnection.ApplicationServer = "AppServer"
sapConnection.HostName = "HostName"
sapConnection.SystemNumber = "00"
sapConnection.System = "000"
sapConnection.Client = "300"
sapConnection.User = "DSOUZA"
sapConnection.Password = "Password"
sapConnection.Language = "EN"


If sapConnection.logon(0, False) Then

	perform check_user(objBAPIControl)

Else
  MsgBox "Could not connect to SAP system".
End If

'Call the BAPI from the SAP system
public sub check_user(objBAPIControl As Object)

Dim objUserBapi As Object
Set objUserBapi = objBAPIControl.Add("BAPI_USER_EXISTENCE_CHECK")

'Input parameters of BAPI
objUserBapi.exports("USERNAME").Value = "TestUser"

If objJobList.Call Then
	dim return as object

'Export parameters of BAPI
	set return = objUserBapi.imports("RETURN")
	msgbox return.value("MESSAGE")

else
 msgbox "Could not execute BAPI".
end if

Read only

0 Likes
937

I will give this a try in VBA, and attempting to get all that I am working on to work there. Once that is done, I will need to migrate that to .NET.

More to come in the next few days.

Read only

0 Likes
937

Dear ,

Did you get the solution in .NET ?

Read only

0 Likes
937

I have had some success, and will post my results if you need. I have not logged into SDN for a while, so sorry for such a late reply.

Read only

0 Likes
937

Hi

I would be very interested in your solution that you used in VB.net if you could please post.

Trevor