Copyright 2024 - BV TallVision IT

Rather than having your report start somewhere, run through a series of routines to end somewhere else, the Object Oriented paradigm evolves around objects. An object is a real-world like "thing" that is being "processed". A car. A purchase order that is ready to be released. An invoice that needs to be checked. An object is an instance of a class. This article should clarify what this means. 

Methods and attributes can be made available or hidden using visibility. Public, protected and private is a settings that can be applied to a method or attribute. Attributes can also be bombarded to "readonly", which makes them visible but unchangeable. Public methods are available (visible) from anywhere. Protected methods are only available to the class itself and all sub classes. Private methods are available only to other methods in the same class. 

The constructor is a rather special method, that any class can have. There are 2 types of constructor, the (regular) CONSTRUCTOR and the CLASS-CONSTRUCTOR. When an object for a class is instantiated, typically with CREATE OBJECT the constructor method on the class is called. The parameters on the constructor need to be passed in the CREATE OBJECT statement (unless they are optional of course).

A (any) class will have a definition section and (if there are methods) an implementation section. Clearly separated. With the object builder the difference is not too appearant, but when you are composing a local class in your coding, the definition and implementation sections are very obvious. This is not an Abap matter, it's all Object Oriented languages going at it in the same way. The available flavours:

CLASS class DEFINITION.
CLASS class DEFINITION DEFERRED. 
CLASS class DEFINITION LOAD.
CLASS class IMPLEMENTATION.

The DEFERRED option is used when you need to refer with a variabele to a class which has not yet been defined. The LOAD option - is well documented.