Reading the Data from Export Parameters
Use
After calling an RFC function you can look at the resulting export parameters by using the IRfcModule and related objects.
Procedures
The following procedures suggest methods you can use for reading the data from export parameters. They are not necessarily the only methods with which you can access this data.
Reading Simple Export Parameters
Example
The following example reads the data from the export parameter SYSTEM_NAME of the RFC function GET_SYSTEM_NAME (The complete code for creating and calling the function is in
Example: RFC Function with an Export Parameter).ISimple sysNameParam = rfcModule.getSimpleExportParam("SYSTEM_NAME");
String sysName = sysNameParam.getString();
Reading Structure Export Parameters
Example
The following example reads one of the fields from the structure export parameter RFCSI_EXPORT of the RFC function RFC_SYSTEM_INFO. The structure export parameter RFCSI_EXPORT contains various fields providing information on the system the client is connected to. The RFCOPSYS field in that structure provides operating system information. It is a string of 10 characters.
// Obtain an instance of the SessionManager and start a session
SessionManager sessionMgr = SessionManager.getInstance();
sessionMgr.open();
// Get a module factory object and create the module
IRfcModule rfcModule = sessionMgr.getRfcModuleFactory().autoCreateRfcModule("RFC_SYSTEM_INFO");
int retCode = rfcModule.callReceive();
// Get the structure export parameter
IStructure sysinfoStruct = rfcModule.getStructExportParam("RFCSI_EXPORT");
//get the value of the RFCOPSYS field
String OpSys = sysinfoStruct.getSimpleField("RFCOPSYS").getString();
System.out.println("Operating System = " + opSys);
// Close the session
sessionMgr.close();
Reading Export Data from Table Parameters
Tables are both import and export parameters. Possible steps for reading the export data from a table parameter:
You can do so with methods of the ITable object (for example getRow) or by using a cursor (using the various get methods of ICursor). You can also use the standard Java ResultSet interface to get at rows of the table. See the detailed discussion in
Example
The code in
Example: Calling an RFC Function with Parameters prints out the contents of the returned table parameter of and RFC function.Also see the examples in
Working with Table Data.