Continuing exploring the Refactoring assistant, we’ll see how we can use the class association in the refactoring assistant.
Find all the posts of Mastering the Class Editor:
- Class Editor – Convert Local Classes to Global Classes
- Class Editor – Refactoring Assistant – I
- Class Editor – Refactoring Assistant – II
Moving components from Class to Associated Class
Refactoring assistant also helps up when we don’t have the class hierarchy but the class association. Association is a reference of an object to another object. Association can be achieved by declaring an attribute using TYPE REF TO object. We’ll use calss ZCL_MAIN as the main class which we have used to declare everything. We should have designed different classes each for Data selection as ZCL_DATA and output as ZCL_ALV to better use Design Pattern MVC.
- Create association classes ZCL_DATA and ZCL_ALV
- Declare attributes with refrence to ZCL_DATA and ZCL_ALV in the main class ZCL_MAIN. Save and Activate
- Open the Class ZCL_MAIN Go to Utilities > Refactoring Assitant. Expand the tree.
- Drag and drop the method get_Data from ZCL_MAIN to ZCL_DATA.
Associated classes will look like this after refactoring: