RFC_OPTIONS 

The structure

typedef struct {
char * destination;
RFC_MODE mode;
void * connopt;
char * client;
char * user;
char * password;
char * language;
int trace;
} RFC_OPTIONS;

provides parameters for RfcOpen.

Depending on the type of connection, various data have to be supplied to open an RFC connection.

There are three ways to supply this information:

  1. You can enter a destination name pointed to an entry in a ‘saprfc.ini’ file which contains the necessary network parameters and RFC-specific parameters for opening the connection at RfcOpen.
  2. You can enter a destination name pointed to an entry in a ‘sideinfo’ file which only contains the necessary network parameters for opening the connection at RfcOpen
  3. In your program you supply all the data needed for opening the connection at RfcOpen.

The first of these methods is recommended (i.e. working with saprfc.ini), because it allows you to use some RFC features today as well as in the future without changing your RFC programs. See sprfc.ini for more details.

Fields that are not supplied must be set to NULL.

The RFC_OPTIONS structure consists of three groups.

This structure must be completely initialized with 0. This will ensure that in the future SAP can add more connection parameters.

This structure is defined in SAPRFC.H.

Members:

name of destination

If the connection is not described completely, this name is used as a key for a ‘sideinfo’ where the connection should then be described. You always have to fill in this field.

connection mode

There are two different protocol types for RFC, depending on whether your target system is an R/2 or R/3 System.

If your target system is an SAP system of Release 3.0C or later, you can use various special options if you enter the value RFC_MODE_VERSION_3 here.

Depending on the contents of this field, connopt must point to different structures (see RFC_MODE).

If connopt is NULL, the ‘sideinfo’ or the ‘saprfc.ini’ file is used to determine the connection parameters.

Without ‘sideinfo.ini’ file connopt must point to a structure of type RFC_CONNOPT_R3ONLY, RFC_CONNOPT_VERSION_3 or RFC_CONNOPT_CPIC depending in the value of ‘mode’.

signon data: client

signon data: user

signon data: password

signon data: language

trace

If 0, no trace is written. If not 0, the RFC library traces all activities into a file ‘dev_rfc’ in the actual working directory.

If your target system is of Release 3.0C or later, you can enter the value ‘D’ here to start the ABAP debugger on the target system.

The ABAP debugger can also be activated by setting the environment varialbe RFC_DEBUG before the call to RfcOpen is done.

Options for an R/3 connection.

// static = initialized structures
static RFC_OPTIONS options;
static RFC_CONNOPT_R3ONLY rfc_connopt_r3only;
RFC_HANDLE handle

options.destination = "TEST";
options.mode = RFC_MODE_R3ONLY;
options.client = "000";
options.user = "SAP*";
options.language = "E";
options.password = "PASS";
options.trace = 0; // turn trace off

options.connopt = &rfc_connopt_r3only;

rfc_connopt_r3only.hostname = "some_host"; // some host name
rfc_connopt_r3only.sysnr = 0; // system 00

handle = RfcOpen(&options);
if(handle == RFC_HANDLE_NULL)
{
...