What is a local Class in OOABAP ? Properties of local class in OOABAP

Local classes in SAP ABAP programming, properties of local classes in SAP ABAP

+ -

Classes are two types in SAP Classes, one is Global class which can be created in SE24 and second one is local class.Local class is a class which have definition and implementation in a program .

Syntax for creating local class is :
*CLASS DEFINITION
CLASS  DEFINITION.  "THIS IS CLASS DEFINITION




ENDCLASS.

*CLASS IMPLEMENTATION
CLASS  IMPLEMENTATION.
*METHODS, EVENTS IMPLEMENTATION
ENDCLASS. 

Defining attributes, methods and events in local classes

All the attributes, methods, events must be defined in between CLASS DEFINITION and ENDCLASS.
Syntax for declaring attributes in local classes
CLASS CL_EXAMPLE DEFINITION. "CLASS DEFINITION
PUBLIC SECTION. "VISIBILITY 
DATA :  TYPE . "DECLARING INSTANCE ATTRIBUTE
CLASS-DATA:  TYPE  . "DECLARING STATIC ATTRIBUTE
ENDCLASS.
Syntax for declaring methods in local classes
CLASS CL_EXAMPLE DEFINITION. "CLASS DEFINITION
PUBLIC SECTION. "VISIBILITY 
*DECLARING INSTANCE METHOD
METHODS : 
          IMPORTING  TYPE 
          EXPORTING  TYPE .

*DECLARING STATIC METHOD
CLASS-METHODS : 
                IMPORTING  TYPE 
                EXPORTING  TYPE .
ENDCLASS.
Syntax for declaring EVENTS in local classes
CLASS CL_EXAMPLE DEFINITION. "CLASS DEFINITION
PUBLIC SECTION. "VISIBILITY 
*DECLARING INSTANCE EVENT
EVENT : .

*DECLARING STATIC EVENT
CLASS-EVENT : .
ENDCLASS.
Syntax for declaring CONSTRUCTOR in local classes
CLASS CL_EXAMPLE DEFINITION. "CLASS DEFINITION
PUBLIC SECTION. "VISIBILITY 
*DECLARING INSTANCE CONSTRUCTOR
METHODS : CONSTRUCTOR
            IMPORTING  TYPE .
*DECLARING STATIC CONSTRUCTOR(CLASS CONSTRUCTOR)
CLASS-METHODS: CLASS_CONSTRUCTOR.


ENDCLASS.

Learner Questions


Please Sign in to ask a question

Was this lesson helpful to you? Yes No 43 People out of 45 think this lesson helpful


Lesson Navigation

Inheritance in SAP OOABAP← Previous Lesson
Next Chapter →