‎2008 May 22 12:06 PM
Dear Experts ,
plz explain me this coe with some suitable example , im unable to understand this . I m new in oo abap .plz help me.
if you have anyb documents regaeding oo abap , plz send me .
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_hours TYPE i
im_hourly_payment TYPE i,
Thanks .
‎2008 May 22 12:09 PM
OO ABAP Info.
Have a look at below link and go to page 1291. It will give you good info abt OO ABAP.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Also have a look at below links:
http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
Please do check transaction ABAPDOCU to learn more about ABAP OO. There are lots of examples and explanations there.
I hope it helps.
Best Regards,
Vibha
Please mark all the helpful answers
‎2008 May 22 12:14 PM
Hello,
Please, see these: [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3e59b790-0201-0010-88aa-bc8a7f95f6fb], [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3412d190-0201-0010-aaaa-ff5a315ae5fe] and [http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf].
Regards.
‎2008 May 22 6:59 PM
Hi Ranjna,
That is the implementation part of the class, in which a constructor will be useful for initializing the class attributes (both public as well as private).
for example
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_hours TYPE i
im_hourly_payment TYPE i,
this particular constructor is useful for initializing the class attributes number, name, hours, hourly_payment when ever an object is created.
in the above example the constructor is importing number , name , hours, payment ....while an object is created and assign these values to the object created from that class.
but we need to see that a constructor cant have exporting or returning parametres. only importing parametres.
we cant call the constructor explicitly, it is called automatically when ever an object is created.
this is just a small part of constructors , again
constructors are two types one is instanc and other is class.
instance constructor is called when ever an object is accessed and an class constructor is called when ever an class is accessed for the first time.
instance constructors will be called as many times as objects created.
class constructor is called only once. i.e when class is first accessed.
this is just basic idea of constructors.....
go through the above links given by others.....it will help u a lot.
best of luck......
cheers
kiran
‎2008 May 23 7:25 AM
Hi,
You need to have some object oriented programming knowledge first, which you can acquire through various links provided by others. Coming to present context,
CONSTRUCTOR is a special method that is called by runtime system as soon as the object has been generated in the memory. This can have only IMPORTING parameters and exceptions.
There are two types of CONSTRUCTORS:
1) Instance constructor:
The CONSTRUCTOR is a special instance method in a class and is always named CONSTRUCTOR. The constructor is automatically called at runtime with the CREATE OBJECT.
2) Static or class constructor:
The static constructor is a special static method in a class and is always named CLASS_CONSTRUCTOR. It is executed no more than once per program or class. The static constructor is called automatically before the class is first accessed. This constructor's signature cannot have IMPORTING parameters or EXCEPTIONS and cannot be called explicitly.
CONSTRUCTOR and CLASS_CONSTRUCTOR are automatically called when you create an object or when you first access the components of the class.
Reward points if you find this useful.
Regards,
Sekhar