
In SAP NetWeaver 7.4 or higher, you can convert a local variable into a parameter.
You can create one of the following parameter types:
Example
The local variable current_speed is to be promoted as a parameter:
CLASS cl_local_variable_parameter DEFINITION PUBLIC CREATE PUBLIC .
PRIVATE SECTION.
CONSTANTS max_speed VALUE 100.
METHODS check_speed
RETURNING
VALUE(result) TYPE i.
ENDCLASS.
CLASS cl_local_variable_parameter IMPLEMENTATION.
METHOD check_speed.
DATA current_speed TYPE i.
IF ( current_speed > max_speed ).
result = abap_false.
ENDIF.
ENDMETHOD.
ENDCLASS.The declaration of the importing parameter (current_speed) is added to the method signature. In addition, the declaration of the former local variable is deleted in the implementation.
Example
ABAP class after conversion:
CLASS cl_local_variable_parameter DEFINITION PUBLIC CREATE PUBLIC .
PRIVATE SECTION.
DATA: result TYPE i.
CONSTANTS max_speed VALUE 100.
METHODS check_speed
IMPORTING
current_speed TYPE i.
RETURNING
VALUE(result) TYPE i.
ENDCLASS.
CLASS cl_local_variable_parameter IMPLEMENTATION.
METHOD check_speed.
IF ( current_speed > max_speed ).
result = abap_false.
ENDIF.
ENDMETHOD.
ENDCLASS.