Show TOC

 Overview of Function ModulesLocate this document in the navigation structure

Use

Function modules are ABAP routines that encapsulate program code and provide an interface for data exchange. Function modules are stored in a central function library. They are not application-specific and are available system-wide. The ABAP Workbench comes with a large number of standard function modules.

Features

Main Features

The main features of function modules are:

  • They belong to a pool called a function group.
  • They possess a fixed interface for data exchange. This makes it easier for you to pass input and output parameters to and from the function module. For example, you can assign default values to the input parameters. The interface also supports exception handling. This allows you to catch errors and pass them back to the calling program for handling.
  • You call a function module by name (which must be unique) in a CALL FUNCTION statement.

Function Groups

Function groups (also called function pools) are ABAP programs of a special type. They are the only program type that can contain function modules. Function modules are, in turn, procedures with public interface and are designed to be used by other programs. Function groups can contain global data declarations and subroutines that are available to all function modules in the group. In terms of object-oriented programming, a function group resembles a class and the function modules are its public static methods. Just like executable programs and module pools, function groups can also contain dynpros as their components, which is not possible in class pools. For that reason, you need to use function groups if you want to work with classical dynpros. The following figure illustrates the organization of function modules within a function group:

FunctionModules

For each function group <fgrp> , the system generates a main program called SAPL<fgrp> . The main program contains INCLUDE statements for the following programs:

  • L<fgrp> TOP: The first include program; contains the global data for the function group.
  • L<fgrp> Uxx: These includes contain the function modules. The numbering xx indicates the sequential order in which the function modules were created. For example, L<fgrp> U01 and L<fgrp> U02 contain the first two function modules in the function group.
  • L<fgrp> F01, L<fgrp> F02... L<fgrp> Fxx: You can use these includes to write subroutines (forms) that can be called as internal forms by all function modules in the group.
    Caution

    These include programs are generated by the Function Builder and may not be changed.

The naming convention for includes is the following (xx indicates a two-digit number):

  • Suffix "Exx": Implementation of methods and classes
  • Suffix "Oxx": Implementation of PBO modules
  • Suffix "Ixx" : Implementation of PAI modules
  • Suffix "Exx": Implementation of event blocks
  • Suffix "Fxx": Implementation of local subroutines

In the top include, you can add include programs with the suffix "Dxx" for the declaration parts of local classes.