All ABAP programs are modular in structure and made up of processing blocks you can modularize source code by placing ABAP statements either global include programs or function modules. The processing blocks that you call from ABAP programs are called procedures.
Modularization makes ABAP programs easier to read and maintain, as well as avoiding redundancy, increasing the reusability of source code, and encapsulating data.
Function modules are procedures that are defined in function groups (type F) and can be called from any ABAP program. Every function module needs a function group which acts as containers.
- Function modules allow you to encapsulate and reuse global functions in the R/3 System.
- Function modules are stored in a central library.
- The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program.
- Function modules play an important role in updating the databases.
- Function modules play an important role in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.
- Function modules also support exception handling. This allows you to catch certain errors while the function module is running.
- The actual ABAP interface definition remains hidden from the programmer. You can define the following
- Function modules can be tested without having to include them in a program.
Please follow the steps to create the function groups and function modules in the ABAP by using function builder.
GOTO–> Tcode: SE37 or Tools -> ABAP workbench -> Development -> Function builder.
Step 1: Create function group first if your not using existing one
Function builder -> Goto -> function groups -> Create function groups.
Step 2: Create function module using the function builder.
Calling function module:
To call the function module, try creating a report and calling the function modules.
Follow the steps as below:
1) Create ABAP Program using ABAP editor ( TCODE: SE38).
2) Define the required Variables.
3) Call function module, by passing the values.