0% found this document useful (0 votes)
10 views

Function Module in ABAP

The document explains Function Modules (FMs) in SAP, which are reusable code segments for encapsulating specific functions or processes, including Regular, Remote, and Update Function Modules. It outlines the components of FMs, such as import/export parameters and exceptions, and provides steps for creating each type of function module. Additionally, it discusses the importance of the COMMIT WORK statement in managing updates and the use of transaction codes like SE37, SE80, and SM13 for function module operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Function Module in ABAP

The document explains Function Modules (FMs) in SAP, which are reusable code segments for encapsulating specific functions or processes, including Regular, Remote, and Update Function Modules. It outlines the components of FMs, such as import/export parameters and exceptions, and provides steps for creating each type of function module. Additionally, it discusses the importance of the COMMIT WORK statement in managing updates and the use of transaction codes like SE37, SE80, and SM13 for function module operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Function Module

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.

Types of Function Module:


1. Regular Function Module: A Regular Function Module is executed immediately and
synchronously within the current SAP system. It is the default type, where function
execution happens directly in the calling program.

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.

3. Update Function Module: An Update Function Module is executed asynchronously,


scheduled for execution in an update work process after the COMMIT WORK statement
is triggered. This is useful for bundling database changes in a single Logical Unit of Work
(LUW), improving performance by handling updates in the background.

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.

Steps to create Regular Function Module:


Step 1: Open SE37 Tcode to create Function modules and Write Function Module name and
click on create.

• 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.

• How to create a function group??


▪ Open tcode SE80.
▪ Select the category as function group under Repository Brower and write the function
group name and click on enter.

• 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 5: Save, Activate and run.

Use of regular function module in report.


Steps to create Remote Function Module:
Step 1: Select the processing type as remote-enable module.

Step 2: And all the parameters should be pass by value and remaining part is same as regular
function module.

Use of Remote function module in report.

It is executed synchronously on the target system, specified in the DESTINATION parameter.


The connection details are configured in transaction SM59.
Once the RFC completes, the calling program resumes execution. The performance might be
impacted depending on the connection quality.
Steps to create Update function module:

Step 1: Select the processing type as update module.

Step 2: And all the parameters should be pass by value.

Changing and exporting parameter is not allow in update function module.


Use of Update function module in report.
• COMMIT WORK: After executing a transaction (like inserting or updating data in the
database), a COMMIT WORK statement is used to trigger the execution of all the update
tasks that are waiting in the queue. This ensures that the updates are processed after the
main transaction is finished, and any database changes are committed to the database.

• 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

The update work process in SM50.

Update requests is SM13

You might also like