Start of Content Area

Background documentation Programming With Visual Basic .NET Locate the document in its SAP Library structure

SAP Connector proxies are generated in Microsoft Visual C# but you can access them in any common language runtime language (Visual Basic, Smalltalk, Python, Managed C++, etc.). The proxy itself must still be created as a C# project and added as a reference to your project. Within C# projects, you can add the proxy code to the same project. While the samples provided with the connector include the SAP proxy code in each project we do not recommend this approach except to illustrate the concepts of the connector. Normally, you create and compile the proxy class separately from the solutions that use the proxy. For example, it is often a good idea to put both the SAP.Connector.dll and the generated proxy into the global assembly cache so that it can be accessed by all projects that require these SAP objects and minimizes the number of proxy components to maintain. Therefore, you can choose which language to use with the SAP .NET Connector.

The SAP toolbox designer components work with both C# and Visual Basic .NET projects. For other languages you may have to add a variable to these classes yourself. The exception to this is the connect code template code. This code is designed to work with C# projects so it will not produce syntactically correct Visual Basic .NET code for connecting and calling the proxy functions. To reproduce the template code manually, is very simple. It involves the following steps:

·        Declare parameters for the call (for example, a proxy object and a connection)

·        Call the RFC method(s)

·        Adding error handling (for example,  Try/Catch/finally)

 

Example in Visual Basic. NET

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        ' Declare parameters here

        Dim proxy As New CompiledProxy.CompiledProxy()

        ' note: compiled proxy is a SAP connector class project in this solution or

        ‘ could be the proxy in the GAC

 

        ‘ get the connection from SAP destination component (added from toolbox)

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

 

        ' Call methods here

        proxy.Rfc_Customer_Get("", txtSelection.Text, BrfcknA1Table1)

 

    End Sub

End Class

 

End of Content Area