Use method CL_RS_DATA=>SWITCH_ORDER( ) :
cl_rs_data=>switch_order( CHANGING c_t_data = lt_my_table ).
Technically, the method loops on table entries and insert each of them with INDEX 1.
Code inside the method :
METHOD switch_order .
FIELD-SYMBOLS: <l_s_data> TYPE any,
<l_t_data> TYPE table.
DATA: l_r_data TYPE REF TO data.
CREATE DATA l_r_data LIKE c_t_data.
ASSIGN l_r_data->* TO <l_t_data>.
LOOP AT c_t_data ASSIGNING <l_s_data>.
INSERT <l_s_data> INTO <l_t_data> INDEX 1.
ENDLOOP.
c_t_data = <l_t_data>.
ENDMETHOD.
About the author