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

  1. Use the getSimpleExportParam of the IRfcModule object to get an ISimple object for the export parameter.
  2. Use one of the get methods of ISimple (Inherited from ISimpleField) to get the value of the parameter depending on the type of parameter (See ISimpleField methods, such as getChar, getInt, and so on in the Java RFC HTML Reference).

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

  1. Use the getStructExportParam of the IRfcModule object to get an IStructure object for the export parameter.
  2. Use methods of the IStructure object inherited from IComplexIField to get the individual fields of the structure. For example, you can use getSimpleField to get an ISimpleField object for each of the fields of the structure.
  3. Use one of the get methods of ISimpleField to get the value of a field in the structure depending on the type of field it is.

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:

  1. Use the getTableParam method of the IRfcModule object to get an ITable object for the parameter.
  2. For each of the rows of the table get an IRow object representing a copy of the row in the table.
  3. 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 Working with Table, Rows, and Cursors.

  4. Use the getSimpleField method of the IRow object (inherited from IComplexIField) to get the ISimpleField object for each of the fields of the row.
  5. Use one of the get methods of ISimpleField to get the value of an individual field in the row.

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.