Different Types of SAP Function Modules: Normal, RFC, and Update - aidamate13/AMS-Knowledge-Base GitHub Wiki

1. Normal/Regular Function Module :-

  • It can be called inside the system.

  • Here Pass by value + Pass by reference both is fine.

2. RFC Function Modules :-

  • You can call from same system or from another possible.

  • In RFC function module you can only have pass by value.

  • In the same system if you are going to add the DESTINATION

  • NONE’ while calling the RFC then it’ll be called in separate session.

3. UPDATE Function Modules :-

  • This is generally used to update the database record.

  • Update Function Module can be called from the same system. ( Background RFC / trfc / grfc )

  • This is used to achieve generally the SAP LUW.

  • Some time we use from performance perspective also.

  • When COMMIT WORK gets executed then Update starts getting executed.


Requirement :-

  • Suppose, we have a vendor portal which is extended to SAP.
  • So, the requirement is when Vendor Login to the Portal, We have to show him the list of Purchase Order though RFC.

Solution :-

Part 1 :- Creating function Module

  • Step 1 :- Go to SE37.

  • Step 2 :- Give name and function group.

image

  • Step 3 :- Open the attributes tab and select remote enabled module.

image

  • Step 4 :- Take import parameters.

image

  • Step 5:- Give a export parameter to display the message in export section.

image

  • Step 6 :- define parameters in tables section.

image

  • Step 7 :- Write the logic in source code.

image

Part 2 :- Creating RFC Destination

  • Step 1 :- go to SM59 and click on ABAP connections.

image

  • Step 2 :- Click on create button.

  • Step 3 :- Provide the destination β†’ connection type β†’ description β†’ target host β†’ instance number

image

Press enter.

  • Step 4 :- Click on Login and security.

  • Step 5 :- In the login and security β†’ provide language β†’ client number β†’ user β†’ password β†’ click on save.

image

  • Step 6 :- Click on Connection test.

image

As you can see connection was successful.

Part 3 :- Calling RFC in the program.

  • Step 1 :- Go to ABAP editor and create a executable program.

  • Step 2 :- Follow the below program.

image

We have used the destination of our RFC.

Code Example :-

*Start of Program
***********************

DATA : lt_ekko TYPE TABLE OF ekko,
       lt_ekpo TYPE TABLE OF ekpo,
       gv_msg  TYPE string.

PARAMETERS : p_lifnr TYPE lifnr,
             p_ebeln TYPE ebeln.

START-OF-SELECTION.

  CALL FUNCTION 'ZAR_VENDOR_PO' DESTINATION 'ZDRFC'
    EXPORTING
      ip_lifnr = p_lifnr
      ip_ebeln = p_ebeln
    IMPORTING
      ep_msg   = gv_msg
    TABLES
      ot_ekko  = lt_ekko
      ot_ekpo  = lt_ekpo.

  IF lt_ekko is not INITIAL.

    CL_DEMO_OUTPUT=>DISPLAY( lt_ekko ).

  ELSEIF lt_ekpo[] is not INITIAL.
    CL_DEMO_OUTPUT=>DISPLAY( lt_ekpo ).

  ELSE.
    WRITE : gv_msg.

  ENDIF.

**********************************
*End of Program