CONSTRUCTOR is a special type of method, it is executed automatically whenever a object is created or instantiated.
These methods are mainly used to set default values in classes.
CONSTRUCTORS are two types in SAP classes.
- CONSTRUCTOR ( Instance Constructor).
- CLASS CONSTRUCTOR (Static Constructor).
These methods can only have importing parameters, there will not be any exporting parameters.
The name of the CONSTRUCTOR method must be CONSTRUCTOR only.
CLASS CONSTRUCTOR (Also called as STATIC CONSTRUCTOR).
It is a type of constructor, this method will be executed automatically whenever a first call to the class is made, the first call may be through instance or through class.
These CLASS CONSTRUCTORS are mainly used to set the default values globally i:e irrespective of instances, these methods will not have any importing and exporting parameters.These methods will be executed only once.
Name of the CLASS CONSTRUCTOR must be CLASS_CONSTRUCTOR.