Server Programming with Manual Creation of Function Objects 

Use

When creating server applications with the Java RFC Class Library you can manually create all the parameter objects for the RFC function you are offering in your application.

When you create server function objects manually you perform more steps than if you let the Java RFC Class Library automatically create those objects: you must construct the parameter objects for each of the server functions offered by your program.

Prerequisite

Set up the two properties files to define the middleware type to use.

Procedure

 

Task Description

1.

Obtain a single instance of SessionManager.

See Obtaining SessionManager for more details and an example.

2.

Obtain a single instance of ServerApp.

See Obtaining the ServerApp Object for more information.

3.

Use the SessionManager to create an IServerFunctionFactory object.

See Using the IServerFunctionFactory Object for more information.

4.

Obtain instances of ISimpleFactory, IStructureFactory and ITableFactory as necessary for constructing the various types of parameters that exist in all the RFC functions that you intend to offer.

For example, if any of your functions contains simple parameters (individual fields), then you need to obtain an ISimpleFactory. If any of your functions contains a structure parameter, you need to also obtain an IStructureFactory, and so on.

Note that you only need to obtain a single factory interface for all the parameters of the same type throughout your program (meaning that you do not need to create the factories separately for each function).

Perform the following steps for every RFC function that you intend to offer in your application:

 

5.

Use the IServerFunctionFactory to create an empty IServerFunction object representing the RFC function. Do so by calling IServerFunctionFactory.createEmptyServerFunction().

See Using the IServerFunctionFactory Object for more information.

Perform the following steps for every parameter of the function:

 

6.

Create the parameter as either a simple, structure, or table parameter object, using the appropriate factory object (ISimpleFactory, IStructureFactory and ITableFactory respectively).

See Using the Parameter Factory Objects for more information.

7.

If the parameter is a structure or a table parameter, then you also have to create and add all of its individual fields. To do so, perform the following steps:

a.

Instantiate an array of SimpleInfo objects representing the fields in the table or structure.

b.

Create an ISimpleField object for every element of that array.

c.

Create a ComplexInfo object for the table or structure.

d.

Assign the array of SimpleInfo objects to the ComplexInfo object.

e.

Use this ComplexInfo object to construct the ITable or the IStructure object, using the ITableFactory or the IStructureFactory respectively.

8.

Call either the addImportParam(), the addExportParam() or the addTableParam() method of IServerFunction to add the parameter objects that you have created in step (6) above to the server function object.

See Adding Parameter Objects to IServerFunction for more information.

9.

Create a server process class that implements the IServerProcess interface. This class implements the process() method of the IServerProcess interface.

This process() method is where you implement the processing logic of the RFC function you intend to offer. The processing logic manipulates the import data received from an incoming call, and generates export data for returning information to the calling client.

See Creating a Server Process for Incoming Calls for more information.

10.

Instantiate a server process object belonging to your new server process class.

11.

Call IServerFunction.setServerProcess(IServerProcess) to store the reference of your server process object in your server function object.

See Associating IServerFunction and IServerProcess for more information.

12.

Call ServerApp.addServerFunction(IServerFunction) to add the newly created and configured IServerFunction object to the single instance of ServerApp you have obtained in step (2).

See Adding IServerFunction to ServerApp for more information.

13.

Call the ServerApp.setAcceptArgs method to set the RFC destination where the server application is to be registered.

See Registering a Server Application at the SAP Gateway for more information.

14.

Adjust the number of threads for processing incoming RFC calls.

See Adjusting the Number of Server Threads for more information.

15.

Call ServerApp.run() to wait for incoming RFC calls and process these calls. See Running a Server Application for more information.

Result

You server application is ready to accept RFC calls from an R/3 system.

See Also

Note that the procedure for manually creating IServerFunction object is very similar to the procedure for manually creating the IRfcModule object (when programming a client application with the Java RFC Class Library).