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;
   unsigned nlen;
   unsigned type;
   void *   addr;
   unsigned leng;
}
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;
   unsigned   nlen;
   unsigned   type;
   unsigned   leng;
   ITAB_H     ithandle;
   RFC_ITMODE itmode;
   int        newitab;
} 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.

In order to send or receive inhomogenous structures or tables use the function RfcInstallStructure. See also the example SRFCTEST.C.

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:

  • To create a table parameter for sending, use the routine ItCreate.
    This routine creates a control structure (defined as ITAB_H) for a table just like the one the SAP System creates automatically for internal tables. This address of the control structure is stored in the handle field of the RFC_TABLE structure.
  • To manipulate a table passed to or from the SAP System (for example: to access, append or delete rows, and so on), use the table-handling routines provided by the API. Do not attempt to manipulate the table using normal C mechanisms.