Modularization Part 8: Parameter Passing — IMPORTING, EXPORTING, CHANGING and RETURNING
Preview · a free account unlocks the full lesson
Design method interfaces correctly: parameter kinds, pass by reference vs VALUE( ), OPTIONAL and DEFAULT, IS SUPPLIED, typing (generic vs concrete), and when RETURNING makes code clearer.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 6 and 7 of this series created classes; a good method interface is what makes a method easy to call correctly and hard to misuse. There are four kinds of method parameters. IMPORTING, for example iv_carrid TYPE s_carr_id, is input and cannot be changed inside the method when passed by reference. EXPORTING, for example et_flights TYPE ty_flights, is output.
CHANGING, for example ct_flights TYPE ty_flights, is both in and out. RETURNING, for example VALUE(rv_count) TYPE i, gives exactly one result, is always passed by value, and is what enables functional-style calls such as IF lo->count( ) > 0.
RAISING, for example zcx_flight_error, declares the exceptions a method can raise — not technically a parameter, but still part of its interface.
On passing mechanics: by reference, the default, makes no copy and is efficient for large tables, and an IMPORTING parameter passed by reference is protected against being changed inside the method. VALUE( ) makes a copy, which is safe but costs time for large data, and is required both for RETURNING and for RFC or update function modules.
One trap to watch for: an EXPORTING parameter passed by reference keeps whatever content it already had until you explicitly overwrite it, so you need to CLEAR your output parameters at the start of the method — or use VALUE( ), which always starts out initial.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Related SAP topics
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.