CLASS in ABAP Objects

Classes in ABAP are used for specifying the templates for ABAP objects, with an abstract description and building instructions for that object.

Two types of classes are there

Global Class: These types of classes are created using class builder tool and will be available globally for all ABAP programs.

Local Class: These types of classes are created in an ABAP program and will ba available only to that program where it defined.


The main components of Classes are

  • Attributes: It contains the data fields like reference variables etc.
    • Instance Attributes: declare them using the DATA statement for defining the instance-specific state of an object
    • Static Attributes: declare them using the CLASS-DATA statement for defining the state of the class that is valid for all instances of the class
  • Methods: Contains the internal procedures to define the behavior of an Object. All the class attributed can be accesses in methods.
    • Instance Methods: It declares using METHODS statement and can have access for all class attributes.
    • Static Methods: It declares using CLASS-METHODS statement and have access only static attributes and trigger static events.
  • Events: Objects or classes can use events to trigger event handler methods in other objects or classes. With events, the handler determines the events to which it wants to react.
    • Instance Events: Defining using EVENTS statement and can be triggered only from instance methods.
    • Static Events: Defining using CLASS-EVENTS statement and can be triggered from all methods.
  • Types: Defining our own ABAP data types with TYPES statement inside a class.
  • Constants: Special static attributes that defined using CONSTANTS statement and its value cannot be changed.


Encapsulation Methods

It specifies the external visibility for the class components.

  • Public Section: It is accessible to all users of the class, and to the methods of the class and any classes that inherit from it.
  • Protected Section: Same as private section from 4.5B release.
  • Private Section: It is only visible in the methods of the same class.


Now let us look into the statements and its syntax for dealing local classes in ABAP programs.


Declaring a CLASS


[INHERITING FROM <superclass>]




[FRIENDS <cif1> <cif 2> …]




Implementing a class.



Declare static attributes



Declare Class methods



Declare Class events


Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes