Creating an RFC Server

Implementing an RFC server which can receive function calls from SAP requires the following steps:

  1. Create a server object and set the necessary parameters: GatewayHost, GatewayService, ProgramID
  2. Create or import one or more FunctionCall prototypes and install them using the InstallFunction method
  3. Subscribe to the IncomingCall event
  4. Run the server and wait for incoming calls. The server will run in another thread, so the main thread can do other work, for example handling GUI updates.
 Sub Main()
   ' create the server and set up connection
   Dim WithEvents srv As RfcServer
   srv = New RfcServer
   srv.ProgramID = "ZRFCCTEST"
   srv.GatewayHost = "mysaphost"
   srv.GatewayService = "sapgw01"
   ' import prototype and install it
   ' (connecting the client session left out for clarity,
   '  it's the same as example #1)
   Dim prototype as FunctionCall
   prototype = Session.ImportCall("BAPI_FLIGHT_GETLIST")
   ' start the server
   ' wait for key press, then exit
   Console.WriteLine("Server running. Press key to stop...")
 End Sub
 Private Sub srv_IncomingCall(ByVal fn As FunctionCall) 
                                               Handles srv.IncomingCall
   Select Case fn.Function
          ' do your event processing here
	      ' ...
   End Select
 End Sub

Sample Projects

Note: The files below are for Visual Studio 2008. Click here to download samples for Visual Studio 2010 instead.

icon Server example for Visual Basic .NET | 26.85 kB | Date: 2011-11-22

A sample project for VB.NET which shows how to create an RFC Server

icon Server example for C# | 80.87 kB | Date: 2011-06-08

A sample project for C# which shows which shows how to create an RFC Server