Converting local classes to global classes

By Shitanshu Sahai, L&T Infotech

Introduction: The document guides you to convert the local classes defined in the program to global classes in the repository.

Summary: Sometimes we need to use our local classes to be used in other programs also, now to achieve this purpose we will need to create global classes. This document wil guide you to change your local classes to global classes.

Step 1:

We need local classes to be converted to global classes. I have shared few steps to create the local classes in a report program as well. Please refer to the below screen shot for the same.

*&---------------------------------------------------------------------*
*& Report  Z_SS_CLASS
*&---------------------------------------------------------------------*
*& Program showing some local class and their implementations
*&---------------------------------------------------------------------*

REPORT  Z_SS_CLASS.
INITIALIZATION.
CLASS CLASS_A DEFINITION.
  
PUBLIC SECTION.
  
DATA A TYPE INT4 VALUE 40.
  
METHODS A1  IMPORTING: NUM1 TYPE INT4
                         NUM2 
TYPE INT4.
ENDCLASS.

CLASS CLASS_B DEFINITION INHERITING FROM CLASS_A.
  
PUBLIC SECTION.
  
DATA B TYPE INT4 VALUE 12.
  
METHODS A2.
ENDCLASS.


CLASS CLASS_A IMPLEMENTATION.

  
METHOD A1.

    A = NUM1 + NUM2.
    
WRITE A.
   
ENDMETHOD.

ENDCLASS.
CLASS CLASS_B IMPLEMENTATION.
  
METHOD A2.
    
WRITE'METHOD A2'.
  
ENDMETHOD.
ENDCLASS.
DATA :OBJ TYPE REF TO CLASS_A,
      OBJ2 
TYPE REF TO CLASS_B,
      NUM1 
TYPE INT4 VALUE 100,
      NUM2 
TYPE INT4 VALUE 133.

START-
OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->A1( NUM1 = NUM1
                     NUM2 = NUM2 ).
CREATE OBJECT OBJ2.
CALL METHOD OBJ2->A2.
CALL METHOD OBJ2->A1( NUM1 = NUM1
                     NUM2 = NUM2 ).

Step2:

Execute the program to check the output. Below screen shot shows the same.

Step 3:

Now go to transaction SE24.

Step 4:

Go to object type-> Import-> Local classes in program

Step 5: Enter the program name in this tutorial its Z_SS_CLASS and click on Import icon as shown in the screen shot.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image