Can you find variables that are no more used in a certain ABAP program or ABAP class? You can delete these variables in a selected part of the source code or in the whole development object in order to make your source code more understandable.

This function considers:

  • Local variables within the scope of a method, function module, or form routine
  • Global variables within a class, function group, or report.

NOTE

In a class, no variables that are declared in the PUBLIC or PROTECTED sections are deleted. The deletion does not delete seemingly unused variables that could be referenced from outside.

Procedure

You can delete all unused variables of the whole development object:

  1. Open the source code editor of the development object.
  2. Within the source code, choose Source > Delete Unused Variables (All) (Ctrl + U) from the context menu.

You can delete all unused variables of a selected area:

  1. Open the source code editor of the development object.
  2. Select the code where you want to delete the unused variables.
  3. From the context menu, choose Source > Delete Unused Variables (Selection) (Ctrl + Shift U).

Result

The unused variable declarations are removed from your source code. All the lines of the former occurrences where an unused variable has been deleted are marked:

If you hold the cursor above this mark, you will see what has been deleted in a popup. In case if you are unsatisfied, choose Ctrl + Z to undo all of the changes.

NOTE

Check your code using Check ABAP Development Object (Ctrl + F2).

NOTE

Deleting an unused variable can cause another variable to become unused. 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.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !