I need to write a FM where I will receive the data type of an element as a string parameter and I would like to declare it like:
DATA: lt_test TYPE TABLE OF (iv_data_type).
where the iv_data type whould be the received type.
I need to write a FM where I will receive the data type of an element as a string parameter and I would like to declare it like:
DATA: lt_test TYPE TABLE OF (iv_data_type).
where the iv_data type whould be the received type.
You should create your internal table dynamically:
DATA lt_test type ref to data.
FIELD-SYMBOLS: <lts_test> type standard table.
CREATE DATA lt_test type (iv_data_type).
ASSIGN lt_test->* to <lts_test>.
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
I_TAB_RAW_DATA = lt_raw_data
TABLES
I_TAB_CONVERTED_DATA = <lts_table>
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
you can try the following
DATA : lo_struct_des TYPE REF TO cl_abap_structdescr,
lo_result_struct TYPE REF TO cl_abap_structdescr.
DATA: lo_new_tab TYPE REF TO cl_abap_tabledescr .
DATA: lt_struct_tab TYPE abap_component_tab.
DATA: tab TYPE REF TO data,
line TYPE REF TO data.
FIELD-SYMBOLS: <fs_data> TYPE ANY TABLE,
<fs_line> TYPE any.
lo_struct_des ?= cl_abap_typedescr=>describe_by_name( 'your_Structure_name_here' ).
lt_struct_tab = lo_struct_des->get_components( ) .
lo_result_struct = cl_abap_structdescr=>create( p_components = lt_struct_tab ) .
lo_new_tab = cl_abap_tabledescr=>create( p_line_type = lo_result_struct
p_table_kind = cl_abap_tabledescr=>tablekind_std
p_unique = abap_false ).
CREATE DATA tab TYPE HANDLE lo_new_tab.
CREATE DATA line TYPE HANDLE lo_result_struct .
ASSIGN tab->* TO <fs_data>.
ASSIGN line->* TO <fs_line> .