
In SAP NetWeaver 7.4 SP05 or higher, you can convert definitions of a local variable, local constant, or local type and paste them into the private section of the current class. Therefore, you can make certain local elements of individual methods available for all methods within an ABAP class.
| Local Elements | Members |
|---|---|
| Local variables | Attributes |
| Local constants | Member constants |
| Local types | Member types |
| Field symbols | Cannot be converted to members |
Example
The local variable current_speed, the local constant max_speed VALUE 100, and the local type zy_speed TYPE i are to be declared in the private section:
CLASS cl_local_variable_expression IMPLEMENTATION. METHOD check_area. DATA: length, width, result TYPE i. IF ( length * width > 100 ). result = abap_true. ENDIF. ENDMETHOD. ENDCLASS.
The source code editor inserts the declaration of the local variable current_speed, the local constant max_speed VALUE 100, and the local type zy_speed TYPE i in the private section of the class definition.
Example
ABAP class after conversion:
CLASS cl_variables_class_members DEFINITION PUBLIC FINAL CREATE PUBLIC .
PRIVATE SECTION.
TYPES zy_speed TYPE i.
CONSTANTS max_speed VALUE 100.
DATA: current_speed TYPE i.
METHODS check_speed
RETURNING
VALUE(result) TYPE i.
ENDCLASS.
CLASS cl_variables_class_members IMPLEMENTATION.
METHOD check_speed.
IF ( current_speed > max_speed ).
result = abap_false.
ENDIF.
ENDMETHOD.
ENDCLASS.