Using the Parameter Factory Objects to Add and Create Parameters
After creating an empty server function object you must create and add the parameter objects for all of the parameters of the function.
To create the necessary parameter objects, you must first obtain the relevant factory objects: ISimpleFactory (for creating simple parameters), IStructureFactory (for creating structure parameters), and ITableFactory (for creating table parameters).
Example
To continue the rfcComputeTax example (in
Using the IServerFunctionFactory), which implements the RFC function RFC_COMPUTE_TAX, the following example adds the appropriate parameter objects to the function.This example shows how to create simple and table parameter objects.
Note that this example assumes that a reference to the SessionManager object is ready for use.
// _sessionMan is a reference to SessionManager
com.sap.rfc.ISimpleFactory simpleFactory = _sessionMan.getSimpleFactory();
com.sap.rfc.IStructureFactory structureFactory =
_sessionMan.getStructureFactory();
com.sap.rfc.ITableFactory tableFactory = _sessionMan.getTableFactory();
com.sap.rfc.ITable _expenseTable = null;
com.sap.rfc.ISimple _name = null;
// Note that a com.sap.rfc.SimpleInfo object is needed to create a
// simple parameter object
_name = _simpleFactory.
createSimple(
new SimpleInfo(null, IFieldInfo.RFCTYPE_CHAR, 32, 0),
"NAME");
// Note that an array of com.sap.rfc.SimpleInfo objects are needed
// to create a com.sap.rfc.ComplexInfo object first, then the
// com.sap.rfc.ComplexInfo object is used to create a table
// parameter or structure parameter object
IFieldInfo[] eTableInfo = new SimpleInfo[4];
int i = 0;
eTableInfo[i++] = new SimpleInfo("EXPENSE_DESCRIPTION",
IFieldInfo.RFCTYPE_CHAR, 200, 0);
eTableInfo[i++] = new SimpleInfo("EXPENSE_TYPE",
IFieldInfo.RFCTYPE_CHAR, 4, 0);
eTableInfo[i++] = new SimpleInfo("DATE",
IFieldInfo.RFCTYPE_DATE, 8, 0);
eTableInfo[i++] = new SimpleInfo("AMOUNT",
IFieldInfo.RFCTYPE_BCD, 8, 2);
_expenseTable = _tableFactory.createTable
(new ComplexInfo(eTableInfo, ""));
_expenseTable.setParameterName("EXPENSE_LIST");
See Also
For the detailed syntax of using the factory methods, see the Java RFC HTML Reference documentation.