Show TOC

 Creating New Function ModulesLocate this document in the navigation structure

Purpose

Function modules perform tasks of general interest to other programmers. Such tasks are performing tax calculations, determining factory calendar dates, calling frequently-used dialogs and so on.

Process Flow

When you write ABAP routines that other programmers might use, define these routines as function modules. You create them in the Function Builder as follows:

  1. Check whether a suitable function module already exists.
  2. Create a function group if no appropriate group exists yet.
  3. Create the function module.
  4. Define the function module interface by entering its parameters and exceptions.
  5. Write the actual ABAP code for the function module, adding any relevant global data to the TOP include.
  6. Activate the module.
  7. Test the module.
  8. Document the module and its parameters for other users.
  9. Release the module.

Runtime Considerations

There are some runtime considerations you should be familiar with when writing function modules:

  • The CALL FUNCTION statement can assign IMPORT, EXPORT, and CHANGING parameters either by value or by reference. Table parameters are always assigned by reference.
  • If you declare parameters referring to ABAP Dictionary fields or structures, the system checks the type and length when the parameters are transferred. If the parameters from the calling program do not pass this check, the calling program is terminated.
  • At runtime, all function modules belonging to a function group are loaded with the calling program. You should plan carefully which functions belong to a group and which do not. Otherwise, calling your function modules increases the amount of memory required by the user.