TYPES: BEGIN OF ty_user,
bname TYPE usr21-bname,
persnumber TYPE adr6-persnumber,
addrnumber TYPE adr6-addrnumber,
smtp_addr TYPE adr6-smtp_addr,
END OF ty_user.
CLASS cl_person DEFINITION.
PUBLIC SECTION.
METHODS: constructor
IMPORTING
i_userdata TYPE ty_user.
METHODS: print_mail.
private SECTION.
DATA: userdata TYPE ty_user.
ENDCLASS.
CLASS cl_person IMPLEMENTATION.
METHOD constructor.
userdata = i_userdata.
ENDMETHOD.
METHOD print_mail.
WRITE: / userdata-bname, userdata-smtp_addr.
ENDMETHOD.
ENDCLASS.
DATA: it_userdata TYPE TABLE OF ty_user.
* interne Tabelle zur Speicherung der Objektreferenzen
DATA: it_persons TYPE TABLE OF REF TO cl_person.
* Objektreferenz
DATA: o_person TYPE REF TO cl_person.
START-OF-SELECTION.
* Daten holen
SELECT u~bname, u~persnumber, u~addrnumber, a~smtp_addr
INTO CORRESPONDING FIELDS OF TABLE @it_userdata
FROM usr21 AS u
INNER JOIN adr6 AS a ON a~persnumber = u~persnumber AND a~addrnumber = u~addrnumber
UP TO 10 ROWS.
* Objekte erzeugen und an Referenztabelle anhängen
LOOP AT it_userdata INTO DATA(wa_user).
o_person = new cl_person( wa_user ).
APPEND o_person TO it_persons.
ENDLOOP.
* Referenztabelle durchloopen und Objekte aufrufen
LOOP AT it_persons INTO o_person.
o_person->print_mail( ).
ENDLOOP.