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.

·        The data needed to establish the physical connection depend on the type of connection. Depending on the contents of the field ‘mode’, the field ‘connopt’ must point to different structures.

·        The signon data (client, user, password, language) are needed for authentication. Since RfcOpen only opens the physical connection directly, these data are only checked if the first RFC call is sent.

·        The third field contains a trace flag. If not zero, a trace file is written for all the operations corresponding to this connection to ease error analysis.

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:

·        destination

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.

·        mode

connection mode

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

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).

·        connopt

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’.

·        client

signon data: client

·        user

signon data: user

·        password

signon data: password

·        language

signon data: language

·        trace

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 connection to an SAP system.

// 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)
{
...