Sometimes, we start designing the class in the program itself. Later in the game, we learn that it would be great if we create this class out of the program and make it global. Thus we can make the class more reusable. We might think, why in the world we started with local class.
To ease this type of situation, we have the import utility available in the Class Editor SE24. Let’s start with our local class. We have a local class LCL_REPORT. We want to make it as global class ZCL_MSG_REPORT.
Code snippet of the local class:
CLASS lcl_report DEFINITION.
DATA: t_t100 TYPE STANDARD TABLE OF t100.
ENDCLASS. "lcl_report DEFINITION
DATA: lo_main TYPE REF TO lcl_report.
CREATE OBJECT lo_main.
CLASS lcl_report IMPLEMENTATION.
SELECT * FROM t100
INTO TABLE t_t100
UP TO 20 ROWS
WHERE sprsl = sy-langu
AND arbgb = '00'.
FIELD-SYMBOLS: <lfs_t100> LIKE LINE OF t_t100.
LOOP AT me->t_t100 ASSIGNING <lfs_t100>.
WRITE: /(30) <lfs_t100>-arbgb,
ENDCLASS. "lcl_report IMPLEMENTATION
Steps to Convert:
- Select Object Type > Import > Local classes in program
- Enter the Program name from which we wish to import the local class. Press Enter
- Select the classes which are required to import and press Import button
- Success message if everything is good
- Methods and Attributes in Class Editor. Activate the class.
Things to Take care after import
- Enter Class Description
- Update Methods and its Signature Description
- Similarly, update all other component description