Parameter Passing: IMPORTING, EXPORTING, CHANGING and RETURNING
Design clean interfaces for methods, function modules and reusable routines.
Explanation
Good modularization depends on clear parameter passing. IMPORTING parameters provide input. EXPORTING parameters return output. CHANGING parameters are both input and output. RETURNING parameters are commonly used in methods for a single return value. Poor parameter design creates confusion and side effects. Too many CHANGING parameters can make code hard to debug because the caller may not know what will be modified. Clean interfaces make code easier to test, reuse and maintain.
Code example
METHODS is_customer_valid IMPORTING iv_kunnr TYPE kunnr RETURNING VALUE(rv_valid) TYPE abap_bool. METHODS enrich_order CHANGING cs_order TYPE zstr_order.Real project scenario
A validation method should receive customer number as importing parameter and return validation result. It should not silently change unrelated global variables.
Common mistakes
- Using CHANGING when RETURNING is enough. - Passing too many parameters. - Modifying global variables inside methods. - Not documenting important parameter behavior.
Best practices
- Use IMPORTING for input. - Use RETURNING for single clear result. - Use CHANGING only when modification is intentional. - Avoid hidden global state.
Interview angle
Interviewers may ask why excessive CHANGING parameters are risky. The answer should mention side effects and maintainability.