Class Editor – Convert Local Classes to Global Classes

By | September 16, 2011 | ABAP Objects, OO Editor tools | 13,592 | 1

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:

PROGRAM ztest_np_temp.

*
CLASS lcl_report DEFINITION.
  PUBLIC SECTION.
    METHODSselect_data,
             write_data.
  PRIVATE SECTION.
    DATAt_t100 TYPE STANDARD TABLE OF t100.
ENDCLASS.                    "lcl_report DEFINITION

START-OF-SELECTION.
  DATAlo_main TYPE REF TO lcl_report.
  CREATE OBJECT lo_main.
  lo_main->select_data).
  lo_main->write_data).

*
CLASS lcl_report IMPLEMENTATION.
  METHOD select_data.
    SELECT FROM t100
      INTO TABLE t_t100
      UP TO 20 ROWS
      WHERE sprsl sy-langu
      AND   arbgb '00'.
  ENDMETHOD.                    "select_Data
  METHOD write_data.
    FIELD-SYMBOLS<lfs_t100> LIKE LINE OF t_t100.
    LOOP AT me->t_t100 ASSIGNING <lfs_t100>.
      WRITE/(30<lfs_t100>-arbgb,
              (70<lfs_t100>-text.
    ENDLOOP.
  ENDMETHOD.                    "write_data
ENDCLASS.                    "lcl_report IMPLEMENTATION

Steps to Convert:

  1. Select Object Type > Import > Local classes in program
  2. Enter the Program name from which we wish to import the local class. Press Enter
  3. Select the classes which are required to import and press Import button
  4. Success message if everything is good
  5. 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

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

1 Comment

  • […] already created a local class in a program and want to migrate that to Global Class, you can use ABAP Editor Tool Convert Local Classes to Global Classes. Join the forum discussion on this post TAGSABAP Objects OO […]

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.