RFC is called Remote function module. As the name suggests using RFC we can interact with an external system that may be a SAP system or a Non SAP system.


RFC Function module is just like a function module created in the Transaction SE37, with some specific constraints that are 

  • The processing type should be Remote-Enabled Module 
  • All the parameters should be of Value type

Let’s check out one example: (Note: To demonstrate RFC example, Two systems are used one is A4H and the other is S4H- both are SAP systems)

Requirement: Get the List of Sales orders for a customer in A4H and display it in the S4H system.
So to achieve the requirement, we need to call an RFC Function module of A4H from the S4H system and the RFC connection (Tcode SM59) should be maintained in S4H -> A4H system.


Let’s first create an RFC function module in the A4H system which will take input as Sold to party (VBAK-KUNNR) and return sales order information.

Steps to Create an RFC Function Module in A4H:

SE37 Transaction
Create Function Module in SE37
Function Module Name and Function Group
Remote Enabled Function Module
Choose Processing Type as Remote Enabled module
Function Module parameter pass by value
The parameter is of type pass by value
FUNCTION ZGET_ORDER_LIST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IP_SOLDTO) TYPE  KUNAG
*"  TABLES
*"      IT_ORDERS TYPE  ZZORDER_DETAILS_T
*"----------------------------------------------------------------------
select  VBELN,
        ERDAT,
        ERZET,
        ERNAM,
        AUART,
        VKORG,
        KUNNR from vbak into TABLE @it_orders
  WHERE kunnr EQ @ip_soldto.

ENDFUNCTION.

Testing FM in A4H system

Test function module
SE16N Transaction
So there are total of 12 entries for this sold to party

Creating an RFC connection from S4H to A4H in order to call the RFC function module in the S4H system.

This step would be created by the Basis team.

SM59 Transaction
Maintain the technical setting and credentials. So that the S4H can communicate with A4H system.

Now create a report and call the Function module.

*&---------------------------------------------------------------------*
*& Report ZTEST_FETCH_ORDERS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztest_fetch_orders.

"Type/Data Declaration
TYPES: BEGIN OF ty_orders,
        vbeln TYPE  vbeln_va,
        erdat TYPE  erdat,
        erzet TYPE  erzet,
        ernam TYPE  ernam,
        auart TYPE  auart,
        vkorg TYPE  vkorg,
        kunnr TYPE  kunag,
  END OF ty_orders.
DATA:lt_orders TYPE TABLE OF ty_orders.
DATA:lr_table TYPE REF TO cl_salv_table.

"Selection screen
PARAMETERS:pa_soldt TYPE kunag OBLIGATORY.

START-OF-SELECTION.

"Call the RFC function Module present in A4H system
CALL FUNCTION 'ZGET_ORDER_LIST' DESTINATION 'A4H'
  EXPORTING
    ip_soldto       = pa_soldt
  TABLES
    it_orders       = lt_orders.

"Call the ALV
cl_salv_table=>factory( IMPORTING r_salv_table = lr_table
                         CHANGING t_table = lt_orders ).
lr_table->display( ).

Test Result in S4H system

Selection screen of report
Execute the report in SE37
Selection screen output
ALV output

Hopefully, this clears the concept of RFC. We will check other details in upcoming blogs. Stay Tune😀

Note:

Detail Link: https://help.sap.com/doc/saphelp_nw73/7.3.16/en-US/48/88068ad9134076e10000000a42189d/content.htm?no_cache=true

check out our OData Series: OData – ABAP Skill


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *