CLASS lcl_calculator DEFINITION.
PUBLIC SECTION.
METHODS calculate_total
IMPORTING it_items TYPE ty_items
RETURNING VALUE(rv_total) TYPE i.
ENDCLASS.
DATA(lo_calc) = NEW lcl_calculator( ).
DATA(lv_total) = lo_calc->calculate_total( lt_items ).
A method with a RETURNING parameter can be used inside an expression, which removes temporary variables. Only one is allowed, and that constraint encourages methods that do one thing.
Check your understanding
Test what you just read.
Quiz 1
Which modularization technique is deprecated for new ABAP development?
Quiz 2
BAPIs are implemented as function modules.
Quiz 3
Which function module parameter receives data from the caller?
Quiz 4
What mechanism allows external systems to call SAP function modules?
Quiz 5
Function modules can exist independently without belonging to a function group.
Quiz 6
Arrange the steps for calling a function module in order.
Click items in the correct order
Hear when the paid version launches
A paid version is in preparation, with no ads, saved learning progress and many more practice questions. Leave your email and you will be told when it launches.
Your email address is used only to announce the paid version.