Posts

Showing posts with the label Constructors

OOPS ABAP: Constructors With Example

Constructors: Constructor is a special type of method which is executed automatically when a object is created. It cannot be called using CALL METHOD. Constructors are methods with a predefined name. Multiple CONSTRUCTOR and CLASS_CONSTRUCTOR are not allowed with in a class.   Types of constructors: CONSTRUCTOR (Instance Constructor) CLASS_CONSTRUCTOR (Static Constructor) Method name: CONSTRUCTOR Method name: CLASS_CONSTRUCTOR It contains import parameters only It does not contain any parameters static and instance attributes can be accessed Only static attributes can be accessed It is called every time when a object is created It is called first time when a object is created Used to set a default value for particular instance   Example: *&---------------------------------------------------------------------* *...