In a source code-based development object, you can delete unused variables in the
entire object or only in marked source code. This enables you to automatically find and
delete unused variable declarations in order to clean up source code.
Prerequisites
This functionality is provided in
SAP NetWeaver Release 7.31 SP06 and
higher as well as Release 7.40 SP02 and higher.
Context
This function deletes the following types of unused variables:
Note Deleting an unused variable can cause another variable to become
unused if it was referenced. The deletion of unused variables does not perform
recursive checks for such variables. It can therefore be useful to run the function
more than once in order to find and delete unused variables in such cases. You can
undo the deletions using the shortcut Ctrl Z.
Example
Before Execution |
After Execution |
To copy the source code example, click here Code Example Before Execution
|
|
The cl_car class contains the
name and i_speed as well
as the private variables current_speed,
delta, temp, and
max public variables.
Except the temp variable, all other variables
are not used.
|
Only the unused current_speed,
delta, and max private
variables have been removed.
Note To see which unused variables have been deleted,
hover the marker in the mark bar and
check the displayed tooltip.
|
Procedure
- You can delete all unused variables of a source code-based development
object:
- In the source code editor, position the cursor anywhere within the
source code.
- Get the quick assist proposals by choosing Quick Fix from the
context menu (shortcut Ctrl 1) or by using the
Quick Assist view.
- Apply or shortcut (Alt U).
- You can delete all unused variables in a selected section of source code:
- In the source code editor, select the source code in the method where
you want to perform the deletion.
- Get the quick assist proposals by choosing Quick Fix from the
context menu (shortcut Ctrl 1) or by using the
Quick Assist view.
- Apply or shortcut (Alt Shift U).