cancel
Showing results for 
Search instead for 
Did you mean: 

Sample ASP.Net code ??

Former Member
0 Kudos

Hi folks,

Ive written an Winform application using VB.net and NCO 3 which is working great 🐵

Im now in the process of teaching myself ASP.Net (Using VB.Net in Visual Studio 2010) and I thought that it would be a good learning experience to convert my winform application to web based .

So , ive got the site running by virtually cutting and pasting most of the code from the winform application but Ive no idea where to start with the NCO part of the code

Does anybody have sample code in VB.net for a simple ASP.net site ?

Thanks in advance

Kev

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Yes, I've a sample Web App and a sample WebService built with .NET Framework 4.0 (VB) using NCo 3.0.

Let me know where how I can send it to you.

Former Member
0 Kudos

Thanks Nicolas,

I will try and PM an email address to you 🐵

Kev

Former Member
0 Kudos

HI K_Hunter,

you have any doubts with below code snippets please let me know. Here i am taking example for login module.

Step 1: First you installed SAP.Net Connector into your machine. You don't have any SAP.Net connector please contact your basis team.

Step 2: Add sapnco.dll, sapnco_utils.dll into your solution. After installing the sap.Net Connector into your machine

these .dll's are available in c>program files>SAP-->SAP.Net connector folder.

Step3: Open your .cs or .vb code behind file.

Imports SAP.Middleware.Connector

Dim config__ As New MyBackendConfig()

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

try

RfcDestinationManager.UnregisterDestinationConfiguration(config__)

RfcDestinationManager.RegisterDestinationConfiguration(config__)

Catch exec As RfcInvalidStateException

Login1.FailureText = exec.Message

Catch exec2 As RfcCommunicationException

Login1.FailureText = exec2.Message

End Try

End If

End Sub

Public Class MyBackendConfig

Implements IDestinationConfiguration

Public Event ConfigurationChanged(ByVal destinationName As String, ByVal args As RfcConfigurationEventArgs) Implements IDestinationConfiguration.ConfigurationChanged

Public Function GetParameters(ByVal destinationName As String) As RfcConfigParameters Implements IDestinationConfiguration.GetParameters

If "SE37".Equals(destinationName) Then

Dim parms As New RfcConfigParameters()

parms.Add(RfcConfigParameters.AppServerHost, "192.168.1.14")

parms.Add(RfcConfigParameters.SystemNumber, "02")

parms.Add(RfcConfigParameters.User, "abaper")

parms.Add(RfcConfigParameters.Password, "erp@1234")

parms.Add(RfcConfigParameters.Client, "800")

parms.Add(RfcConfigParameters.Language, "EN")

parms.Add(RfcConfigParameters.PoolSize, "5")

parms.Add(RfcConfigParameters.MaxPoolSize, "10")

parms.Add(RfcConfigParameters.IdleTimeout, "600")

Return parms

Else

Return Nothing

End If

End Function

Public Function ChangeEventsSupported() As Boolean Implements IDestinationConfiguration.ChangeEventsSupported

Return False

End Function

End Class

Note: Please find remaining content in below post........

Former Member
0 Kudos

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

Dim prd As RfcDestination = RfcDestinationManager.GetDestination("SE37")

Dim repo As RfcRepository = prd.Repository

Dim companyBapi1 As IRfcFunction = repo.CreateFunction("ZBAPI_EMPLCOMM_GETDETAIL")

companyBapi1.SetValue("EMPLOYEENUMBER", Login1.UserName)

companyBapi1.SetValue("PASSWORD", Login1.Password)

companyBapi1.Invoke(prd)

Dim ir As IRfcStructure = companyBapi1("EMPNUMBER").GetStructure()

Dim ir1 As IRfcStructure = companyBapi1("RETURN").GetStructure()

If ir("PERNR").GetString() "00000000" Then

//redirect to next page

Else

Dim msg As String = ir1("MESSAGE").GetString()

End If

End Sub

End Class

Best Regards,

Harish.Y

Former Member
0 Kudos

HI,

You have any concerns regarding how integrate asp.net and sap. Please read my wiki in sdn. Below i give the link to you.

http://wiki.sdn.sap.com/wiki/pages/editpage.action?pageId=263291953

Best Regards,

Harish.Y