I have a incoming deep structure in my recursive method which contains structures and tables, so I'm working with RTTI to check type, loop over it and do my operation, in case I found a specific component.
If the current component is a structure or table, then method calls itself.
Problem: I import the structure with type any. So far so good. And i want to export it as type any also.
And here I struggle.
How can I assign my edited deep structure to my export parameter ?
METHOD process_input.
DATA: lo_type_descr TYPE REF TO cl_abap_typedescr,
lo_struct_descr TYPE REF TO cl_abap_structdescr,
lv_comp_found TYPE abap_bool.
FIELD-SYMBOLS: TYPE ANY TABLE,
TYPE any.
lo_type_descr ?= cl_abap_typedescr=>describe_by_data( p_data = im_input ).
IF lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct2 OR
lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct1.
lo_struct_descr ?= cl_abap_structdescr=>describe_by_data( p_data = im_input ).
LOOP AT lo_struct_descr->components ASSIGNING FIELD-SYMBOL().
ASSIGN COMPONENT sy-tabix OF STRUCTURE im_input TO .
lo_type_descr ?= cl_abap_typedescr=>describe_by_data( p_data = ).
lv_comp_found = abap_false.
IF lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct2 OR
lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct1 OR
lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_table.
process_input(
EXPORTING
im_input =
im_list = im_list
).
ELSE.
READ TABLE im_list INTO DATA(element) WITH KEY service_part = -name BINARY SEARCH.
IF sy-subrc EQ 0.
= 'TEST :)'.
ENDIF.
ENDIF.
ENDLOOP.
ELSEIF lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_table.
ASSIGN im_input TO .
LOOP AT ASSIGNING FIELD-SYMBOL().
lo_struct_descr ?= cl_abap_structdescr=>describe_by_data( p_data = ).
LOOP AT lo_struct_descr->components ASSIGNING .
ASSIGN COMPONENT sy-tabix OF STRUCTURE TO .
lo_type_descr ?= cl_abap_typedescr=>describe_by_data( p_data = ).
lv_comp_found = abap_false.
IF lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct2 OR
lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_struct1 OR
lo_type_descr->type_kind EQ cl_abap_typedescr=>typekind_table.
process_input(
EXPORTING
im_input =
im_list = im_list
).
ELSE.
READ TABLE im_list INTO element WITH KEY service_part = -name BINARY SEARCH.
IF sy-subrc EQ 0.
= 'TEST :)'.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
get REFERENCE OF im_input INTO lv_cont.
ex_input = im_input.
ENDMETHOD.