cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with .Net connector losing connection

Former Member
0 Kudos

I'm writing my first .Net connector project (i.e. please be gentle with me!) - it's an ASP.NET page (using vb.NET) that connects to SAP and checks for failed jobs.

It works fine the first time it runs - calls the Bapi_Xmi_Logon then calls Bapi_Xbp_Job_Select.

I've got a timer set up that calls the subroutine that calls Bapi_Xbp_Job_Select every 30 seconds - but this fails after the first time with "Object reference not set to an instance of an object" - the only way to prevent this seems to be to call the logon routine every time.

Is this how it should work?, or should the logon remain until I explicitly close it?

Any help gratefully received, and sorry if I'm being thick!

Martin Dolphin

Bentley Motors Limited

martin.dolphin@bentley.co.uk

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

Hi Martin,

it might be that you use the SAPLoginProvider for Login (in conjunction with Login form). In this case you must not close the connection. The connection is stored in session state and will be automatically closed on session end event.

If this information doesn't help, you might want to post some code snippets.

Regards,

Reiner.

Former Member
0 Kudos

Hi there and thanks for your response. I'm not using the login provider, but connecting as follows:

Dim myLogon As SAPProxyDll1.BAPIRET2, SessionID As String

Destination1.Language = "E"

Destination1.Client = 500

Destination1.SystemNumber = 0

Destination1.Password = "xxxxxx"

Destination1.Username = "JOBMON"

Destination1.AppServerHost = "gbbyv115"

proxy.Connection = New SAP.Connector.SAPConnection(Me.Destination1)

Destination1 is a sapconnection dragged from the toolbar. Proxy is defined at the top of the form as follows:

Public proxy As New SAPProxyDll1.SAPProxyDll1

When I call the BAPI to find out details of cancelled jobs I have a routine that calls the following:

proxy.Bapi_Xbp_Job_Select("JOBMON", myJobSelection, myJobHeader, myJobDetails, mySelectedJobs)

At no time am I closing the connection, so rather confused - is it something to do with the way I've declared the proxy variable perhaps?

Thanks again.

Martin

reiner_hille-doering
Active Contributor
0 Kudos

Currently you create a new RFC connection for each call and never close it.

proxy.Connection = New SAP.Connector.SAPConnection(Me.Destination1)

You should either keep the connection open (store is somewhere - for Web applications usually in Session state) or open and close in on each request.