
In an ABAP class or ABAP interface, you can move a member definition between the public, protected, and private sections in order to switch its availability.
This refactoring option can be triggered for the following member types:
| Current Section | Option 1 | Option 2 |
|---|---|---|
| Private | Make protected | Make public |
| Protected | Make private | Make public |
| Public | Make private | Make protected |
Example
The speed_check method is moved from the private section to the public section:
CLASS cl_visibility_member DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION . PRIVATE SECTION . METHODS: speed_check. ENDCLASS.
Some refactoring aids decrease (public > protected > private > local) the visibility of members of a class.
So, if the visibility of the target section is more restrictive than in the current section, the refactoring will check whether any usages exist that will no longer be available after the change. In this case, the developer is informed and can decide to reject or apply the change.
Increasing VisibilitySome refactoring aids increase (local > private > protected > public) the visibility of members or locals inside a class.
So, if the visibility of a member (or local) is increased, subsequent processing might depend on other declarations that are no longer visible for the member. In this case, the developer is informed and can decide to reject or apply the change.
The source code editor moves the entire member definition to the selected section.
The cursor remains at the original position. This enables you to move further members into another section directly from your current position.
Example
The member of the speed_check method is moved to the public section:
CLASS cl_visibility_member DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION . METHODS: speed_check. PRIVATE SECTION . ENDCLASS.