Skip to main content
Version: 5.6

SAP RFC Transfer Object Example

This example demonstrates how to call an RFC function module using an SAP RFC transfer object. The function module Z_FM_ADD is used as an example; its import, export, and source code are shown in the following figures.

Function Module in the SAP® System

Function module Z_FM_ADD in the Function Builder

note

In the general properties, select the "Remote callable" option so that this function module can be called by third-party systems, such as the OPC Router. Otherwise, this function module can only be called within the current SAP system.

Import

Function module Z_FM_ADD – Import

Export

Function module Z_FM_ADD – Export

Source Code

Function Module Z_FM_ADD – Source Code

note

The function module must then be saved, checked, and activated (Save, Check, and Activate in the Function Builder, transaction SE37). Only an active function module marked as remote-capable can be called via RFC from the OPC Router.

Create a Transfer Object

In the OPC Router, select the SAP-RFC transfer object for a new connection.

In this example, the function module Z_FM_ADD is located in the function group ZZ_TEST_OPC. A connection named Vm-Sap was created in the SAP® plug-in to access it.

Double-click to open the SAP-RFC transfer object and perform the following steps on the “Settings” tab:

  1. Select Vm-Sap in the “SAP Connection” field.
  2. In the “Function Group” section, click “Filter” in the “Search Filter” field to load the function groups.
  3. Select ZZ_TEST_OPC in the “Function Group” field.
  4. In the “Function” section, click “Filter” in the “Search Filter” field to load the functions.
  5. Select Z_FM_ADD in the “Function” field.

SAP RFC Transfer Object – Settings

On the “Parameters” tab, select the imports and exports.

SAP RFC Transfer Object – Parameters

After confirming with “OK,” the SAP RFC transfer object looks as follows:

SAP RFC Transfer Object for Z_FM_ADD

Configure the Connection

As shown in the following figure, In_Param1 and In_Param2 are set to constants, and RESULT is assigned to a variable.

Connection to the SAP RFC transfer object

Deploy the change

Next, click “Deploy the change” at the top of the page and confirm again by clicking “Deploy the change” in the “Publish” section.

Deploy Change to Production

Trigger the connection and check the result

Next, trigger the connection in the Status Indicator by right-clicking on your connection and selecting “Trigger Connection.”

Triggering the connection in the status display

As expected, the value of RESULT is equal to the sum of In_Param1 and In_Param2.

Result of the RFC call in the status display