04-03-2008 9:46 AM
Hi,
how can I define a class A that has a member that is a table
that holds pointers to instances of A?
In Java, I would have written
class A {
private List<A> followers = new ArrayList<A>();
.....
hope this helps to understand the question.
Thanks in advance,
Stefan
04-03-2008 10:26 AM
Hi,
Just have a look at the code excerpt below.
Create a class like
CLASS LCL_CLASS DEFINITION.
**put here your components.
ENDCLASS.
Implement your class.
then in your main program
write
data plane_list TYPE TABLE OF REF to lcl_airplane.
*this creates a ref variable which stores all the instances of that class.
use this may be this can be helpful.
Regards,
Khushboo
04-03-2008 2:09 PM
Hello,
Please read this [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0a33479c-0b01-0010-7485-dc8c09d6bc69], it's a good workshop that have good expanations concerning ABAP Objects with figures that can help you to associate ABAP OO with Java.
And [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25a3df90-0201-0010-10b6-9712397c22fd] is a text that compares the two technologies.
Regards,
04-14-2008 9:09 PM
Hello Stefan,
you need to declare a type that is an internal table of the class type. In newer releases you may define such a type within the class-pool itself. In older releases you need to stress the data dictionary.
Regards
Klaus
program z_Sample.
class lcl_Sample definition.
public section.
types:
ty_Samples type standard table of ref to lcl_Sample with default key.
methods:
get_Aggregated_Samples
returning
value(result) type ty_Samples.
private section.
data: f_Samples type ty_Samples.
endclass.