Constructor methods ABAP Objects

Go down

Constructor methods ABAP Objects

Post  Admin on Sat Mar 31, 2012 11:23 pm


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.


Admin
Admin

Posts : 92
Join date : 2012-01-26

http://mysaplab.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum