Calling RFC Functions


Communication between the tester and the SAPphone server takes place using the RFC-API (Remote Function Call – Application Programming Interface). External communication takes place between an SAP System (the SPS tester) and a non-SAP System (the SAPphone server). For more information, see The RFC Interface.

This process describes the typical process flow of a function call using the RFC-API:

Process Flow

  1. Determination of the Handle

    The handle of the current server has to be determined every time an RFC function is called. This is because when external communication takes place, the RFC connection is automatically separated after a function is executed, that is, the handle is no longer recognized after a function call.

  2. Allocation of Memory Areas

Memory areas must be allocated in order to transfer data to an RFC function or to receive data from an RFC function. Both the RFC function itself and the RFC calling program must access these memory areas in order to be able to process the data. Data can be numeric or alphanumeric. The RFC-API enables the transfer of tables.

The memory allocation is generated using RfcAllocParamSpace (1.Parameter, 2.Parameter, 3.Parameter). The parameters mean:

    • 1. Parameter: Number of data to be exported into the RFC function.
    • 2. Parameter: Number of data to be imported from the RFC function.
    • 3. Parameter: Number of tables that are defined for data transfer or data evaluation for an import or export.
    • Result: Pointer to the reserved memory areas
  1. Type Assignment and Data Transmission

    The data type of the data to be exported is communicated to the RFC-API before the function is executed using the function RfcDefineExportParam. The export data is written in the memory areas reserved for it using the function RfcAddExportParam.

    The table data is assigned a type and is transferred to the RFC-API using ItCreate (for type assignment) and RfcAddTable (data transfer).

  2. Execution of the Function

    The execution of the function is initiated using the RFC function RfcCallReceiveExt.

  3. Reading of the data areas by the called RFC Function

    In the case of non-table data, the data can be read from the memory using the function RfcGetImportParam. Table data is stored by the called RFC function in a text line, which must be read completely from the table using the function ItCpyLine. The calling program must recognize the exact structure of this character string in order to be able to access the corresponding data specifically. The character string does not contain separators. It is only the position in the character string that gives information about the data concerned.

    In the tester, this data is imported in an array structure, which is in turn assigned to a table. This table is created in the main program before the function call, is transferred to the function call with Call By Reference and is filled, as described above, at the end of the executed function.

  4. Release of the Allocated Memory Areas

The memory areas that were allocated are released again using the function RfcFreeParamSpace.

The following diagram illustrates a function call: