Constructor methods ABAP Objects
Page 1 of 1
Constructor methods ABAP Objects
Constructor methods are special method that are implicitly associated with every instance
of a class .They are implicitly defined by the system .Constructor methods are called
automatically whenever an object is created .However the constructor methods can be
explicitly defined by the programmer .
We can define the number of input parameters for the constructor .A point to note a constructor method cannot return any value. The name of the constructor method is implicitly defined by the system as “CONSTRUCTOR” and it
cannot be changed . To use a constructor method i.e to incorporate some features , we need
to explicitly define it in class definition part .There are two types of constructor method Static and instance constructor.
- Code:
CLASS my_class DEFINITION.
PUBLIC SECTION.
METHODS CONSTRUCTOR. “ note constructor should be always declared in public.
ENDCLASS.
CLASS my_class IMPLEMENTATION.
METHODS CONSTRUCTOR.
write :/ ‘this is constructor method’.
ENDMETHOD.
ENDCLASS.
Similar topics
» Constructor and inheritance in ABAP Objects with example
» Static and instance constructor in ABAP Objects
» Introduction to methods in ABAP Objects
» Dynamic registration and de-registration of handler methods in ABAP Objects
» Dynamic registration and de-registration of handler methods in ABAP Objects
» Static and instance constructor in ABAP Objects
» Introduction to methods in ABAP Objects
» Dynamic registration and de-registration of handler methods in ABAP Objects
» Dynamic registration and de-registration of handler methods in ABAP Objects
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Mon Aug 20, 2012 4:37 pm by Admin
» Difference between Type and Like
Thu Jun 07, 2012 2:40 pm by Admin
» How to handle table control fields in Module Pool program?
Wed May 09, 2012 2:41 am by govind
» Three tables inner join in SAP
Thu May 03, 2012 4:47 pm by Uma_ABAP
» Creating table type in ABAP
Sat Apr 28, 2012 9:03 pm by Uma_ABAP
» Creating user defined types and structures in ABAP
Sat Apr 28, 2012 8:55 pm by Uma_ABAP
» Creating Dynamic Internal Table and Dynamic Field catalog in SAP-ABAP
Fri Apr 27, 2012 11:00 am by Admin
» Copy Custom PF-Status from Standard program to Custom Program in ALV
Thu Apr 26, 2012 9:52 pm by Uma_ABAP
» Calculate/find number of working days between two dates in SAP
Tue Apr 24, 2012 2:06 pm by Uma_ABAP