Function Module in ABAP
Function Module in ABAP
Function Module (FM) is a reusable piece of code that encapsulates a specific function or
process.
Function modules allow developers to implement business logic in a modular way. They can be
used to perform various tasks such as data validation, calculation, communication with other
systems, and more.
Syntax:
CALL FUNCTION <function module name>.
2. Remote Function Module: A Remote Function Module is used to call functions on other
SAP or non-SAP systems through the RFC (Remote Function Call) protocol. It is
executed synchronously on the target system, specified in the DESTINATION parameter.
The connection details are configured in transaction SM59.
Syntax:
CALL FUNCTION <Function module name> destination <destination name>.
Once the RFC completes, the calling program resumes execution. The performance might
be impacted depending on the connection quality.
Syntax:
CALL FUNCTION <update function module name> IN UPDATE TASK.
This ensures that updates are processed asynchronously, and ROLLBACK WORK can be
used to delete update registrations if necessary.
Components of a Function Module:
1. Import Parameters: Parameters that are passed into the function module when it is
called.
2. Export Parameters: Parameters that return values from the function module after
execution.
3. Changing Parameters: Parameters that are passed in and can be modified within the
function module, with the updated values passed back to the caller.
4. Tables: Internal tables used for passing large amounts of data between the function
module and the caller.
5. Exceptions: Used to handle exceptional situations or errors that occur during the
execution of the function module.
• A pop up displayed which will be asking function group and short text.
• What is function Group?
Function Group is a container or collection of Function Modules that are logically
related to each other. A function group is used to group together function modules that
share a common purpose, allowing them to be managed and organized together.
• Click On yes and you will get the below pop-up screen.
• Enter the Short text and click on save.
▪ Now successfully the function group will be created.
Step 2: Enter the Function Group and short text and click on save.
Step 3: Fill the required parameters (Import, export, changing, table).
Step 4: Write the logic in source code area.
Step 2: And all the parameters should be pass by value and remaining part is same as regular
function module.
• During program execution (SE38), when the statement CALL FUNCTION <name of the
function module> IN UPDATE TASK is encountered, the function module is not
executed immediately. Instead, it is placed in a queue for execution by a special work
process known as the update work process (in SM50 we can see the update work
process). The actual execution of this update work process is triggered by the COMMIT
WORK statement.
• The transaction code for update requests is SM13