Hi
I created editable alv
i created one custom button in tool bar of alv name COPY.
when user select any row and click copy that row should copy other wise it should through error message like 'select at least one row '.
here while copy i am not changing any data in alv.
for this requirement i wrote code in handle_user_command , if e_ucomm = 'COPY'
i called method get_selected_rows is this is intial then thorough the error .
first time i click on copy with out selecting any row it showing error , if i click copy again it is through out of the screen ,
can any one tell me how to rectify this issue see below my code.
METHOD handle_user_command.
* BREAK-POINT.
cl_gui_cfw=>set_new_ok_code( e_ucomm ).
IF e_ucomm EQ 'COPY'.
DATA : lv_row TYPE lvc_t_row,
lv_id TYPE lvc_t_roid,
lv_id1 LIKE LINE OF lv_id,
l_valid TYPE char1.
DATA : i_final2 TYPE TABLE OF t_final,
w_final2 TYPE t_final,
lv_index1 TYPE sy-index,
lv_index2 TYPE sy-index,
w_final4 TYPE t_final,
lv_no TYPE i.
data : lo_data_changed type ref to cl_alv_changed_data_protocol,
ls_outtab LIKE LINE OF i_final.
REFRESH lv_id.
CLEAR : lv_index1 , lv_index2 , lv_no , w_final2 .
CALL METHOD v_alvgd->get_selected_rows
IMPORTING
et_index_rows = lv_row
et_row_no = lv_id.
READ TABLE lv_id INTO lv_id1 INDEX 1.
lv_index1 = lv_id1-row_id .
IF LV_ID1-ROW_ID NE '0'.
i_final_temp[] = i_final[].
REFRESH i_final.
DESCRIBE TABLE i_final_temp LINES lv_no.
READ TABLE i_final_temp INTO w_final INDEX lv_index1.
APPEND w_final TO i_final_temp. " index lv_index2.
i_final[] = i_final_temp[].
REFRESH i_final_temp[].
i_re_alv-row = 'X'.
i_re_alv-col = 'X'.
CALL METHOD v_alvgd->refresh_table_display
EXPORTING
is_stable = i_re_alv .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ELSE .
message 'select at least one row' type 'E'.
ENDIF.
Thanks in advance
kiran