ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Modularization units
Function Modules and Subroutines
Other versions: 7.31 | 7.40 | 7.54
Function modules and subroutines are the procedures of the structured programming model that already existed before the introduction of ABAP Objects.
- Function modules in function groups are independent repository objects that the structured model provides for external calls or for the provision of reusable functions.
- Before the introduction of ABAP Objects, subroutines could be created in any programs and were intended for internal calls or for the internal modularization of programs in the structured model.
The introduction of ABAP Objects means that methods now have both roles.
No implementations in function modules and subroutines
Only use function modules and subroutines if they are necessary from a technical viewpoint. In these cases, do not implement the required function. Instead, call the relevant (local) methods.
This rule is directly derived from rule Use ABAP Objects. This rule states that only methods should be created. You are only allowed to create other types of procedures if is technically not possible to use a method:
- Function modules for RFC, updates, and access to classical dynpros or selection screens
- Subroutines for
PERFORM ON COMMIT/
These subroutines should only be used for wrapping method calls to ensure that ABAP Objects is also used in these cases.
All the rules in these programming guidelines that relate to procedures actually refer to methods because, strictly speaking, no other procedures with nontrivial code are supposed to occur. If you strictly adhere to the above rule, is almost impossible for any of the rules that refer to implementations of procedures to be applied to function modules and subroutines, because they only serve to wrap calls. For example, function modules and subroutines should no longer contain any of the local declarations that are described in "Defining Local Declarations at the Start of a Procedure".
If you cannot adhere to the rule "Use ABAP Objects" and the above rule because, for example, existing legacy function modules and subroutines need to be maintained or enhanced and you cannot switch to methods, the rules in these programming guidelines that refer to procedures also apply to function modules and subroutines.