One object can interact with another by accessing its attributes directly in a method, calling methods, or triggering an event3 Classes consist of source code containing the definition of possible objects. An object is always an instance of a class, which is addressed by at least one reference variable. All components and properties of its objects are declared in a class. Thebasis for encap-sulation in ABAP Objects is always the class, rather than the object.1 Classes are either global for all programs or local in a sin-gle program. They can be specialized by inheritance, and can incorporate standalone interfaces as a public inter-face.Attributes describe the status of an object. Technically speaking, attributes (instance attributes) are the local variables of an object, which cannot normally be changed directly from the outside. A class may also contain static attributes, which are jointly used by all objects of the class.Static attributes may be variables or con-stants.Methods allow objects to perform operations.
A method (instance method) always works in a specific object. In other words, it reads and changes the status of this object, and interacts with other objects by calling their methods or by triggering events. A method has a parameter interface, and can pass on exceptions. A class may also contain static meth-ods, which only accessstatic attributes,and can only trigger static events.
Methods in their fundamental role as the operational components of classes. examines the parameter interface of methods in more detail, and focuses in particular on the various options with method calls.
ABAP Objects supports simple inheritance, whereby a class can be declared as the direct subclass of exactly one superclass. All classes of ABAP Objects are part of an inheritance hierarchy tree originating in one common superclass. In addition to its own components, a subclass also contains the components of its superclass. The implementation of superclass methods can be overwritten in subclasses.
The public visibility section of a class is its external interface. ABAP Objects allows you to create standalone interfaces, which can be used by classes as part of their interface, or even as their complete interface. Objects belonging to various classes that use the same interface can be handled by outside users in the same way. An standalone interface may also comprise several other interfaces
Objects in a program can only be accessed by object references in object reference variables. The type of the object reference variables determines exactly what a program can do with an object. There are both class reference variables and interface reference variables. The latter enable exclusive access to the interface components of a class. The concepts of inheritance and independent interfaces allow you to assign object references between reference variables of different types according to certain rules. This opens up the possibilities of polymorphism, whereby the same reference variable can be used to access objects belonging to different classes with different behavior.