Code: Alles auswählen.
data list_of_objects type standard table of ref to class_of_object with default key.
data object_of_class type ref to class_of_object.
* Einfügen
create object object_of_class.
append object_of_class to list_of_objects.
* Einzeln auslesen
read table list_of_objects into object_of_class index 1.
* Alle auslesen
loop at table list_of_objects into object_of_class.
" object_of_class ausgeben
endloop.
Code: Alles auswählen.
CLASS lcl_object_collection DEFINITION.
PUBLIC SECTION.
METHODS:
constructor,
add_object IMPORTING io_object TYPE REF TO object,
get_iterator RETURNING value(ro_iterator) TYPE REF TO cl_object_collection_iterator.
PROTECTED SECTION.
DATA o_object_collection TYPE REF TO cl_object_collection.
ENDCLASS.
...
CLASS lcl_object_collection IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT me->o_object_collection.
ENDMETHOD.
METHOD add_object.
me->o_object_collection->add( io_object ).
ENDMETHOD.
METHOD get_iterator.
ro_iterator = me->o_object_collection->if_object_collection~get_iterator( ).
ENDMETHOD.
ENDCLASS.
...
*** Im Hauptprogramm:
DATA: lo_dummy_object TYPE REF TO lo_dummy_object,
lo_object_collection TYPE REF TO lcl_object_collection,
lo_iterator TYPE REF TO cl_object_collection_iterator.
CREATE OBJECT lo_object_collection.
lo_object_collection->add_object( lo_dummy_object ).
FREE lo_dummy_object.
lo_iterator = lo_object_collection->get_iterator( ).
WHILE lo_iterator->has_next( ) = 'X'.
lo_dummy_object ?= lo_iterator->get_next( ).
" und dann, je nach Objekt, wie gewünscht ausgeben
ENDWHILE.