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.
- Step 3 :- Open the attributes tab and select remote enabled module.
- Step 4 :- Take import parameters.
- Step 5:- Give a export parameter to display the message in export section.
- Step 6 :- define parameters in tables section.
- Step 7 :- Write the logic in source code.
Part 2 :- Creating RFC Destination
- Step 1 :- go to SM59 and click on ABAP connections.
-
Step 2 :- Click on create button.
-
Step 3 :- Provide the destination β connection type β description β target host β instance number
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.
- Step 6 :- Click on Connection test.
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.
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