‎2009 Jul 04 4:18 AM
Dear Experts,
I would like to know how can I create a TYPE with recursive structure. The main objective is to construct an internal table for my organization structure and then export it to XML using simple transformation. Currently, I can only export this XML by construct the XML document like a string composition which is harder to read and modify.
Regards,
Alex
‎2009 Jul 04 5:13 AM
You want something like in java (from wikipedia article)
class List<E> {
E value;
List<E> next;
} That's only possible in ABAP using data references.
TYPES: BEGIN OF list,
e TYPE i,
pn TYPE REF TO data,
END OF list.
DATA: lp_data TYPE REF TO data.
FIELD-SYMBOLS: <ls_list> TYPE list.
CREATE DATA lp_data TYPE list.
ASSIGN lp_data->* TO <ls_list>.
* Add elements
DO 10 TIMES.
<ls_list>-e = sy-index.
CREATE DATA <ls_list>-pn TYPE list.
ASSIGN <ls_list>-pn->* TO <ls_list>.
ENDDO.
<ls_list>-e = 11.
* Display elements
ASSIGN lp_data->* TO <ls_list>.
WRITE: / <ls_list>-e.
DO.
IF <ls_list>-pn IS INITIAL.
EXIT.
ENDIF.
ASSIGN <ls_list>-pn->* TO <ls_list>.
WRITE: / <ls_list>-e.
ENDDO.Don't know if that helps with your XML question.
matt