Skip to main content

Configure RFC Server in SAP S/4HANA

RFC (Remote Function Call) is a mechanism provided by SAP that allows functions or function modules to be called either within an SAP system or between SAP and non-SAP systems. Using RFC, external programs—referred to as RFC servers—can be triggered by SAP to execute their functions. OctoMesh can be utilized as such an external platform to provide RFC server processes that can be called from SAP via a defined RFC destination.

Basic Workflow

  • Within SAP, you create an RFC destination that points to an external program (the RFC server in OctoMesh).
  • The RFC server registers itself with the SAP Gateway using a previously defined Program ID.
  • SAP can then call RFC-enabled function modules or procedures in the external system (OctoMesh).

Create a pipeline running an RFC server

  1. Create or extend the sap configuration in the Admin Panel under the General/Configuration section. Typically, the configuration should define the following fields:

    • Configuration Name: The name of the configuration, must match the sapConfiguration field in the pipeline configuration.
    • App Server Host: The host of the SAP system.
    • System/instance Number: The system number of the SAP system, e. g. 00
    • System ID: The system ID of the SAP system, e. g. S4H
    • Client (tenant): The client number of the SAP system, e. g. 100
    • User: The username to log in to the SAP system.
    • Password: The password to log in to the SAP system.

    Additionally, we need to define the following fields:

    • Gateway Host: The host of the SAP Gateway, e. g. vhcals4hci
    • Gateway Service: The service of the SAP Gateway, e. g. sapgw00
    • Program ID: The Program ID that the RFC server will register with the SAP Gateway, e. g. NWRFC_OCTOMESH_ID
    • Registration Count: The number of registrations that the RFC server will perform with the SAP Gateway, e. g. 1
  2. Create a pipeline that runs the RFC server. The pipeline should contain the following nodes:

    • FromRfcServerCall@1: The trigger node that listens for RFC calls from SAP. The configuration should define the following fields:

      • SAP Configuration: The name of the SAP configuration created in the previous step.
      • Function Name: The name of the function module that the RFC server will accept calls for.
      triggers:
      - type: FromRfcServerCall@1
      sapConfiguration: sap-test-system
      functionName: Z_OCTOMESH_TEST_FUNCTION
      transformations:
      - type: Logger@1
      message: "RFC Server called"

Configuration in SAP

There are two main steps to configure an RFC server in SAP. The gateway host and service must be defined in the RFC destination, and the function module must be created and marked as remote-enabled.

Create RFC destination

To run an RFC server program, some configuration needs to be done

  • Create RFC destination by executing transaction SM59
  • Enter Destination string a select connection type T

  • After clicking ok, select Registered Server Program as Activation Type
  • Enter description.
  • Enter Program ID
  • Leave gateway options empty or set it to the name of the gateway server (e. g. the hostname of the HANA DB server vhcals4hci)

Edit hosts file

  • Add to C:\Windows\System32\drivers\etc\hosts this entries
# S4H Appliance
<External IP Address SAP S4HANA/HDB server> vhcals4hci.dummy.nodomain vhcals4hci
vhcals4hcs.dummy.nodomain vhcals4hcs vhcalhdbdb vhcaldhbdb.dummy.nodomain
<IP Address SAP NW JAVA/ASE/ADS server> vhcalj2eci.dummy.nodomain vhcalj2eci
vhcalj2ecs.dummy.nodomain vhcalj2ecs vhcalj2edb vhcalj2edb.dummy.nodomain
<IP Address SAP BI Platform > bihost bihost.dummy.nodomain

Info (for me as DAU)

  • HDB = HANA DB
  • ADS = Adobe Document Services
  • SAP BI = is same

Edit GW external security

There is also possible to set according security information to enable external RFC programs.

For that go to transaction SMGW, and select in menu:

About SAP Gateway Security Files there is a lot of information available.

It is also possible to set the host name to '*' to allow all hosts for testing purposes.

Create a function module

In SAP, a function module is a reusable piece of code that can be called from other ABAP programs. By making a function module "remote-enabled," it becomes accessible via Remote Function Calls (RFC). Remote-enabled function modules can be called from different systems, including external environments.

  1. Access the Function Builder (SE37)

    • Log on to your SAP system.
    • Enter the transaction SE37 in the command field and press Enter.
  2. Create a New Function Module

    • In the "Function Module" field, enter a name for your function module. Typically, custom function modules start with Z or Y, for example: Z_OCTOMESH_TEST_FUNCTION.
    • Click the "Create" button or press F8.
  3. Enter Basic Details

    • In the popup dialog, enter a short text description for your function module, e.g., "My Remote-Enabled Function Module".
    • Choose a function group in which the function module will be stored. If you don’t have an existing function group, you can create one by clicking the "New Function Group" button.
    • Click Save.
  4. Mark the Function Module as Remote-Enabled

    • On the "Attributes" tab, look for the "Processing Type" option.
    • Select "Remote-Enabled Module" from the dropdown list. This is crucial for allowing RFC calls.

    Note: Once set to "Remote-Enabled," the function module becomes available for RFC calls. Ensure that any code within the function module is RFC-compatible (for example, no direct user input prompts, no direct file system access, etc. unless specifically handled).

  5. Define Import/Export/Changing Parameters

    • Go to the "Import" tab and define any input parameters your function module needs.
    • Go to the "Export" tab for output parameters.
    • Use "Changing" and "Tables" tabs if necessary.
      Make sure to set the parameter types and specify if they are optional or mandatory.
  6. Add Documentation (Optional but Recommended)

    • On the "Documentation" tab, provide details on what the function module does, what its parameters are, and any other relevant notes.
  7. Write the ABAP Source Code

    • On the "Source Code" tab, write the code logic that you want to execute remotely.
    • Keep your code modular, and ensure no non-RFC compliant commands are used.
  8. Check and Activate

    • Click on the "Check" button or press Ctrl+F2 to verify syntax.
    • If no errors are found, click the "Activate" button or press Ctrl+F3 to activate the function module.
  9. Test Your Function Module

    • In SE37, you can test your function module locally by pressing F8 (Test/Execute).
    • For testing remote calls, you can use RFC-enabled test tools or call it from another system/client.

After testing, use the pipeline debugging functionality to see the data that was received by the RFC server.