Passing Parameters

Five API routines pass parameters back and forth to the remote function. These routines are:

RfcCall and RfcReceive

RfcCallReceive

RfcGetData and RfcSendData

The parameters are passed in one of two structures: RFC_PARAMETER and RFC_TABLE. When your program calls one of these routines, it must provide information about all parameters being passed by filling in these structures.

Passing Import/Export Parameters

Exporting and importing fields are passed to the remote function in an array of RFC_PARAMETER structures:

typedef struct
{
void * name; /* Name of the field (in the interface */
/* definition of the function) */
unsigned nlen; /* Length of the name */
/* (should be strlen(name)) */
unsigned type; /* Datatype of the field */
void * addr; /* Address of the field to be exported */
/* or imported */
unsigned leng; /* Length of the field in Bytes */
}
RFC_PARAMETER;

Arrays must be terminated by an entry with name equal to NULL. The supported ABAP datatypes (see Table 4-1) are defined in saprfc.h (see ABAP Data Types).

ABAP Data Types Supported by the RFC API

Data type

Typedef

Length in Bytes

Description

TYPC

RFC_CHAR[]

1-65535

Characters, blank padded at the end

TYPX

RFC_BYTE[]

1-65535

Binary data

TYPP

RFC_BCD[]

1-16

BCD numbers (Binary Coded Decimals)

TYPINT

RFC_INT

4

Integer

TYPFLOAT

RFC_FLOAT

8

Floating point

TYPDATE

RFC_DATE

8

Date ("YYYYMMDD")

TYPTIME

RFC_TIME

6

Time ("HHMMSS")

Currently, only scalar data types are supported. Record structures will be supported in the future.

Passing Internal Tables

Almost all the RFC sending and receiving functions have two parameters where the exported or imported fields and the referenced ‘internal tables’ are specified. The parameters are pointers to arrays of the structure RFC_PARAMETER. The arrays have to be terminated by an entry with name equal NULL.

Internal tables parameters are passed to the remote function in an array of RFC_TABLE structures:

typedef struct
{
void * name; /* Name of the table (in the interface */
/* definition of the function) */
unsigned nlen; /* Length of the name */
/* (should be strlen(name)) */
unsigned type; /* Datatype of the lines of the table */
unsigned leng; /* Width of the table */
ITAB_H ithandle; /* Table handle (control structure */
/* the internal table. */
IT_MODE itmode; /* Only for RfcGetData. Must contain */
/* the value ITMODE_BYREFERENCE. */
}
RFC_TABLE;

Currently, only scalar data types are possible. That is, only single-column tables and tables with similar columns (only TYPC or only TYPX fields) are supported. ABAP internal tables are described by the similar structure RFC_TABLE.

The type definition for ITAB_H is void *. Note that the itab_h table handle must be supplied by the calling program in RfcCall. Use the routine ItCreate to create an itab_h table handle (see ItLeng for more information).

When receiving a call with RfcGetData, itab_h is filled automatically by RfcGetData.

For the field itmode, you should specify that the table is to be passed by reference (value ITMODE_BYREFERENCE). This notion has a special meaning in the context of remote calls that differs slightly from the conventional meaning (see Parameter Handling in Remote Callsfor more information).

Creating and Manipulating Table Parameters

Tables passed as parameters to an RFC function must match SAP internal tables in their structure and handling.

As a result: