Show TOC

Converting Locals to Class MembersLocate this document in the navigation structure

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.

Prerequisites

This functionality is provided in SAP NetWeaver Release 7.31 SP11 and higher as well as Release 7.40 SP05 and higher.

Context

Note In the following table, you can see the local elements that can be converted to the corresponding member:
Local Elements Members
Local variables Attributes
Local constants Member constants
Local types Member types
Field symbols Cannot be converted to members

Example

Before Execution After Execution

To copy the source code example, click here Code Example Before Execution

The speed variable is declared local variable inside the implementation of the drive method.

The local declaration has been removed and replaced by an attribute declaration.

The attribute has been added to the private section.

Procedure

  1. In the implementation part, position the cursor on the corresponding local declaration (variable, constant, or type).
  2. Get the quick assist proposals by choosing Quick Fix from the context menu (shortcut Ctrl 1) or by using the Quick Assist view.
  3. Apply Convert 'local variable' to attribute, Convert 'local constant' to constant, or Convert 'local type' to class type.