Monday, February 7, 2011

Creating global class from a local class

In this tutorial, we would look into the procedure of creating a global class using a local class defined in a program.

Consider the following Z program, which contains a local class:

REPORT  zclass_test.
*---------------------------------------------------------*
* CLASS zcl_test DEFINITION
*---------------------------------------------------------*
*
*---------------------------------------------------------*
CLASS zcl_test DEFINITION.
PUBLIC SECTION.
    METHODS: display.
ENDCLASS. "zcl_test DEFINITION
*--------------------------------------------------------*
* CLASS zcl_test IMPLEMENTATION
*--------------------------------------------------------*
*
*--------------------------------------------------------*
CLASS zcl_test IMPLEMENTATION.
  METHOD display.
WRITE: 'SAPTechnical.com'.
ENDMETHOD. "display
ENDCLASS. "zcl_test IMPLEMENTATION

Now let us create a global class SE24 using the above local class:

Go to transaction SE24.

Now select Object type à import à Local classes in program (As shown below):

Following pop-up appears:

Enter your Z program in which the local class is defined and press ENTER.

The class name defined in our program is ZCL_TEST and the proposed global class name is CL_ZCL_TEST. Now you can rename the global class name as per your requirement.

If the local class is defined inside an include, we need to check the checkbox “Explode INCLUDEs’.

Now click on import. Following message would appear:

Now check the global class ZCL_TEST.

2 comments:

satbir said...

Hi
this procedure is not correct for create global class
i follow ll steps but last when global class created wo i can't show in class builder. it show this class does not exits message.

levalisoft said...

thanks for sharing this simple and impressive tutorial. I am learning classes and this explains me how to use SE24/SE80 in comparison to those codes.

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites