‎2006 Sep 22 10:43 AM
Hi,
I'm working on a small transaction, in which I already defined some classes. In the TOP include for this transaction, I'm trying to define a reference to an object by writing:
DATA objref TYPE REF TO student.
Student is a class, inheriting from the Person abstract class.
This doesn't work, I get an error saying that 'STUDENT' is unknown. The weird thing is, if I do:
DATA objref TYPE REF TO person.
It works fine...
I really don't understand this at all, so if someone have an idea of what's going on, please give me a hand
‎2006 Sep 22 10:50 AM
hi Thomas,
As i understand, there are some already defined classes. and you are trying to define a reference to an object which is the child of some class(person) in TOP include.
The subclass(student) does not exist in the include that is the reason you are not able to crreate the ref to this. However, as the parent class(person) exist in this include you can create an object ref to this class.
I would suggest you to either define the subclass in the top include or define the reference to the object(student) in the main program.
Regards,
Richa
‎2006 Sep 22 10:49 AM
Hello,
Where you defined the classes and where are you trying to create object.
Regs,
Venkat
‎2006 Sep 22 10:50 AM
Thomas,
As u said here that student is inherted from person. Object reference should be created first for that.
Check the below links for OO ABAP:
/people/sap.user72/blog/2005/05/10/a-small-tip-for-the-beginners-in-oo-abap
http://www.geekinterview.com/Interview-Questions/Concepts/OOPS
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.erpgenie.com/abap/OO/eg.htm
http://www.brabandt.de/html/abap_oo.html
http://www.erpgenie.com/sap/abap/OO/index.htm
Also check the transaction ABAPDOCU there are lot of programs related to OOPS.
Regards,
Prakash.
‎2006 Sep 22 10:50 AM
hi Thomas,
As i understand, there are some already defined classes. and you are trying to define a reference to an object which is the child of some class(person) in TOP include.
The subclass(student) does not exist in the include that is the reason you are not able to crreate the ref to this. However, as the parent class(person) exist in this include you can create an object ref to this class.
I would suggest you to either define the subclass in the top include or define the reference to the object(student) in the main program.
Regards,
Richa
‎2006 Sep 22 10:58 AM
Here is my program (orders of the different includes):
INCLUDE ZSRS_OBJ_TOP.
INCLUDE ZSRS_OBJ_CLASSES.
...
All my classes (including Person) are defined and implemented in the ZSRS_OBJ_CLASSES include. That means I even shouldn't be able to do:
DATA objref TYPE REF TO person.
in my TOP ?
‎2006 Sep 22 11:17 AM
Problem solved: I removed the classes include from the program code and put in on top of the TOP include, just after the PROGRAM statement.
Thanks for the help.