cancel
Showing results for 
Search instead for 
Did you mean: 

SAP logon pad with NCo and visual studio 2003

Former Member
0 Kudos

Hi All,

I'm struggling to find a way in visual studio 2003 utilising the dot net connector to allow the user to select the SAP system, client user name and password in a similar way that happens when done with activeX controls.

E.g. with ActiveX this sort of code:

Dim sapConn As Object 'Declare connection object

Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object

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

The false in the last line prevents a silent logon i.e. a little pop up window is created with the server, client etc. for the user to select and fill in.

I have been trying to use methods like availabledestinations and getdestinationbyname as well as the destinationname property of the saplogon proxy I dropped on my form. In fact I can see all the destinations when I drop down on the destinationname property on the proxy logon object. I though of maybe binding this to a list box but I can't seem to get that to work.

I also tried setting the SAPgui value to 0,1 or 2 on the proxy logon object but this had no effect.

Is there not a simple way of doing this similar to the ActiveX approach?

PS. This is a windows forms project and not a web project.

Thanks,

Grant.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Grant,

Drag and drop SapLogonDestination object of SAP proxy toolbox on your windows form.

And as this implements Idictionary interface, you can enumerate through it as follows in order to retrieve the values-

For Each _destEntry As System.Collections.DictionaryEntry In SapLogonDestination1.AvailableDestinations

Dim _destText As String = _e.Value.ToString

Dim _destKey as String = _e.Key.ToStirng

Next

Once you have these values you can do anything with it. May be, while retreiving these values, create a Table and later bind it to some datacontrol like listbox, datagrid etc.

Regards.

Former Member
0 Kudos

Hi Jitesh,

Thanks for the quick response!

I declared _e as an iDictionaryEnumerator, is that correct?

So the code looks like this:

Dim _e As IDictionaryEnumerator

For Each _destEntry As System.Collections.DictionaryEntry In SapLogonDestination1.AvailableDestinations

Dim _destText As String = _e.Value.ToString

Dim _destKey As String = _e.Key.ToString

Next

I get a Nullreference error: Object reference not set to an instance of an object at the line Dim _destText As String = _e.Value.ToString.

What have I done wrong?

Thanks,

Grant.

Former Member
0 Kudos

Hi Grant,

Just replace _e with _destEntry. You do not need to use _e.

So, the code should look like-

For Each _destEntry As System.Collections.DictionaryEntry In SapLogonDestination1.AvailableDestinations

Dim _destText As String = _destEntry.Value.ToString

Dim _destKey As String = _destEntry.Key.ToString

Next

Regards.

Former Member
0 Kudos

Thank you - that's excellent!

Kind regards,

Grant.

Answers (0)