Modularization
ABAP DevelopmentIntermediate

Function Modules and Function Groups

Understand function modules, function groups, global data and where FMs still matter.

Explanation

Function modules are reusable ABAP units stored inside function groups. They have defined import, export, changing and table parameters, and can raise exceptions. Function groups can hold global data shared by multiple function modules in the group. Function modules are still important because many SAP standard APIs, BAPIs, IDoc utilities, update task modules and RFC integrations are based on them. However, for new internal business logic, classes and methods are often preferred because they support cleaner object-oriented design and better testability.

Code example

ABAP Code
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  EXPORTING    wait = abap_true. CALL FUNCTION 'Z_VALIDATE_CUSTOMER'  EXPORTING    iv_kunnr = lv_kunnr  IMPORTING    ev_valid = lv_valid  TABLES    et_return = lt_return.

Real project scenario

A custom interface may call BAPI_SALESORDER_CHANGE or BAPI_ACC_DOCUMENT_POST. These are function modules with defined parameters and return structures. A developer must understand how to pass data, read return messages and handle COMMIT correctly.

Common mistakes

- Ignoring RETURN table messages. - Changing shared function group global data without impact analysis. - Using function modules for logic that should be a class method. - Not understanding update task or RFC attributes.

Best practices

- Keep FM interface clean. - Avoid unnecessary function group global state. - Read and handle return messages. - Prefer classes for new reusable internal logic.

Interview angle

A strong answer should explain function group, function module interface, global data and why BAPIs/RFCs still use function modules.