You can reuse a member or local constant that has already been generated. Note that all occurrences of the same literal remain unchanged.
Example
Before Execution | After Execution |
---|---|
CLASS cl_car DEFINITION. PUBLIC SECTION . METHODS: drive IMPORTING i_speed TYPE i. PRIVATE SECTION . CONSTANTS max_speed TYPE i VALUE 220. DATA: current_speed TYPE i. ENDCLASS. CLASS cl_car IMPLEMENTATION. METHOD drive. IF i_speed > 220. current_speed = 220. ELSE. current_speed = i_speed. ENDIF. ENDMETHOD. ENDCLASS. To copy the source code example, click hereCode Example Before Execution |
CLASS cl_car DEFINITION. PUBLIC SECTION . METHODS: drive IMPORTING i_speed TYPE i. PRIVATE SECTION . CONSTANTS max_speed TYPE i VALUE 220. DATA: current_speed TYPE i. ENDCLASS. CLASS cl_car IMPLEMENTATION. METHOD drive. IF i_speed > max_speed. current_speed = max_speed. ELSE. current_speed = i_speed. ENDIF. ENDMETHOD. ENDCLASS. |
The literal '200' is to be replaced with an existing constant | In the source code of the ABAP class, all occurrences of the literal are replaced with the name of the existing constant. |