What is CONSTRUCTORS in SAP OOABAP ?

What is a constructor method in SAP Classes ? and Uses of Constructor method in OOABAP

+ -
What is a constructor in a class ?

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.

  1. CONSTRUCTOR ( Instance Constructor).
  2. CLASS CONSTRUCTOR (Static Constructor).

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.

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 63 People out of 64 think this lesson helpful


    Lesson Navigation

    Events in Object Oriented ABAP← Previous Lesson
    Next Chapter →