cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Basic .net

Former Member
0 Kudos

Hi,

we are using visual basic .net applications . How to login the sap login ..and how to pass the parameters to bapi

Prakash

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

i have written the following code to connect sap

Dim r3lon As New SAP.Connector.SAPConnection

Dim r3des As New SAP.Connector.SAPLogonDestination

r3des.AppServerHost = "192.168.1.221"

r3des.Client = "200"

r3des.SystemNumber = "00"

r3des.Username = "Prakash"

r3des.Password = "chariji1"

r3lon.ConnectionString = r3des.ConnectionString

r3lon.Open()

but it is not working . i got error when assigning the application ip to appserverhost. is it the right procedure ?

reiner_hille-doering
Active Contributor
0 Kudos

Try this:

Dim r3des As New SAP.Connector.SAPLogonDestination

r3des.AppServerHost = "192.168.1.221"

r3des.Client = "200"

r3des.SystemNumber = "00"

r3des.Username = "Prakash"

r3des.Password = "chariji1"

Dim r3lon As New SAP.Connector.SAPConnection(r3des)

r3lon.Open()

Former Member
0 Kudos

Thanks for ur valuable reply....

when r3des.appserverhost getting error like ...that s readonly property ... so i changed the following code

Dim r3des As New SAP.Connector.SAPLogonDestination

Dim r3one As New SAP.Connector.Destination

r3one.AppServerHost = "192.168.1.221"

r3one.Client = 200

r3one.Language = "E"

r3one.Username = TextBox2.Text

r3one.Password = TextBox1.Text

r3one.SystemNumber = "00"

Dim r3lon As New SAP.Connector.SAPConnection(r3one)

r3lon.Open()

now i got User not authorized. Session terminated error ....is any settings we have to do in SU01 transaction ?

Former Member
0 Kudos

thank u all .....

The username password is case sencitive ...when i give that in caps lock ..it is working ...

reiner_hille-doering
Active Contributor
0 Kudos

> Thanks for ur valuable reply....

> when r3des.appserverhost getting error like ...that s

> readonly property ... so i changed the following

That's true. The difference between SAPLogonDestination and Destination is that SAPLogonDestination takes some settings from SAPLOGON.INI, while in Destination you have to specify everything:

Dim r3one As New SAP.Connector.Destination

r3one.AppServerHost = "192.168.1.221"

r3one.Client = 200

r3one.Language = "E"

r3one.Username = TextBox2.Text

r3one.Password = TextBox1.Text

r3one.SystemNumber = "00"

Dim r3two As New SAP.Connector.SAPLogonDestination()

r3two.DestinationName = "My R3";

' AppServerHost and SystemNumber are taken from SAPLOGON.

r3two .Client = 200

r3two .Language = "E"

r3two .Username = TextBox2.Text

r3two .Password = TextBox1.Text

Former Member
0 Kudos

Thanks Reiner,

Now i can able to login my sap system . in the next step can i get retrive any sap table to visual basic recordset?..I tried with bapi control.But icant know the exact syntax... so can u tell me how to retrive the data by using BAPI libraries ....

reiner_hille-doering
Active Contributor
0 Kudos

In Visual Basic .NET there is nothing like a "Recordset". Please play with the tutorial that comes with NCo (see VS online help). The sample deal with RFC_CUSTOMER_GET that is unfortunately not available in all SAP systems. If it is not available in your system, please try BAPI_FLCUST_GETLIST (BOR object FlightCustomer, method GetList). It is very similar and also easy to use.

The functions return a list as a so-called SAPTable. The generated class has all features you need, e.g. you can sort and filter it and you can databind any MS control to it. If you really need, you can also convert it to an ADO.NET DataTable, but I don't recommend this.

Answers (0)