ABAP Functions

Function Modules are part of programs that can be stored globally, and in this way used by all ABAP programs. These Function Modules are inside Function Groups. By using them, the developer can take advantage of modularization.

Function Groups

Function Groups are a special type of ABAP Program; they are not executable programs, so they can not be started using a transaction code. Their only purpose is to serve as main programs for function modules. Generally, a Function Group contains many functions modules which perform related functions or that operate on similar data.

When a program calls a Function Module, the Function Group (that is, the main program) is loaded into the internal session, and it stays there until the calling program ends. So, if another function of the same group is called in the same program, the Function Group will be loaded only once. As a consequence, the values of the variables is kept from one call to another (within the same function group, during the execution of the same caller program).

Function groups can contain the following elements besides Function Modules:

  • Global Data Objects (data declarations)

  • Subroutines

  • Screens

Any function module from the function group can use these elements.

The Main Program (Function Group) is composed by Includes. The name of the main program is SAPL<function_group_name>. The includes in the main program are:

  • TOP include -> L<function_group_name>TOP: contains the FUNCTION-POOL statement and the global data declaration

  • U Includes -> L<function_group_name>Uxx: these are the actual function modules

  • F Includes -> L<function_group_name>Fxx: subroutines that can be accessed through internal calls by all the function modules.

  • O Includes -> L<function_group_name>0xx: PBO modules of the screens in the Function Group

  • I Includes -> L<function_group_name>Ixx: PAI modules of the screens in the Function Group.

These includes are generated automatically when creating the function group and its objects.

Function Modules

The Function Modules are the actual functions that are called in the ABAP Programs. The have an interface that consists of: input parameter, output parameters, table parameters and exceptions.

In the Function Modules the developer inserts the code that will be available for reutilization in all the ABAP Programs.

Function Groups and Function Modules are both created and mainained through the Function Builder (transaction SE37); you can also access the Function Builder throuh the ABAP Workbench (transaction SE80).