Creating an RFC Server
Implementing an RFC server which can receive function calls from SAP requires the following steps:
- Create a server object and set the necessary parameters: GatewayHost, GatewayService, ProgramID
- Create or import one or more FunctionCall prototypes and install them using the InstallFunction method
- Subscribe to the IncomingCall event
- 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") srv.InstallFunction(prototype) ' start the server srv.Serve() ' wait for key press, then exit Console.WriteLine("Server running. Press key to stop...") Console.ReadLine() srv.Shutdown() End Sub Private Sub srv_IncomingCall(ByVal fn As FunctionCall) Handles srv.IncomingCall Select Case fn.Function Case "BAPI_FLIGHT_GETLIST" ' do your event processing here Case "BAPI_FLIGHT_GETDETAIL" ' ... 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.
A sample project for VB.NET which shows how to create an RFC Server
A sample project for C# which shows which shows how to create an RFC Server
