2009 Jan 21 6:44 PM
Hi Everyone,
I have an ALV list which has checkboxes. Now when we select the check boxes and press enter it should take me back into the program with only those lines in an internal table for which the checkboxes have been clicked. Is this possible.
Any input is greatly appreciated.
Thanks
Kumar.
2009 Jan 21 7:28 PM
i have not used checkboxes on an ALV, but have used multiple selection with the selection box. it returns the SAME internal table, and you need to loop over the table looking for checkboxes that are set, and processing them one at a time.
Hi Everyone,
I have an ALV list which has checkboxes. Now when we select the check boxes and press enter it should take me back into the program with only those lines in an internal table for which the checkboxes have been clicked. Is this possible.
Any input is greatly appreciated.
Thanks
Kumar.
2009 Jan 21 7:17 PM
If I declare a hotspot and use AT-LINE SELECTION its taking me back to the program but this is not possible for multiple lines at the same time. Is there a better option??
Kumar.
2009 Jan 21 7:28 PM
i have not used checkboxes on an ALV, but have used multiple selection with the selection box. it returns the SAME internal table, and you need to loop over the table looking for checkboxes that are set, and processing them one at a time.
2009 Jan 21 7:31 PM
@David
Do you have any sample code. It returns only the line I click irrespective of the number of lines for which the check box is clicked. The problem is maybe because I am using hotspot logic. I am not able to think of any other logic. Does your ALV list come back to the program with multiple lines in the internal table?
Thanks
Kumar.
2009 Jan 21 7:40 PM
yes... perhaps it is in how you are processing it. i am NOT using hotspots. i created a GUI status with a icon, and assigned it to a specific OK_CODE. then, when you display the ALV,
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_grid_title = w_alv_title
is_layout = t_alvlayout
it_fieldcat = t_alvfieldcat
it_events = t_alveventcat
it_sort = t_alvsortcat
i_save = i_save
is_variant = default_layout
i_default = 'X' " Allow Display Variants
i_callback_program = w_alv_callback_prog
i_callback_user_command = w_alv_command_handler
i_callback_pf_status_set = w_alv_gui_status_setter
i_callback_top_of_page = 'STANDARD_LIST_HEADING'
tables
t_outtab = t_alvdata
exceptions
program_error = 1
others = 2.
you specify a command handler callback, with the callback program and form
w_alv_command_handler = 'ALV_COMMAND_HANDLER'.
w_alv_callback_prog = sy-repid.
then the handler would do something like this
form alv_command_handler using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
read table alvdata into alvline index rs_selfield-tabindex.
case r_ucomm.
when 'DELETE'.
* make sure at least one line was selected
read table alvdata into alvline with key select = true.
if sy-subrc <> 0.
message i014.
else.
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = 'Delete Confirmation'
text_question = 'Are you sure?'
text_button_1 = 'Yes'
text_button_2 = 'No'
default_button = '2'
display_cancel_button = ' '
importing
answer = answer
exceptions
text_not_found = 1
others = 2.
if sy-subrc = 0 and answer = '1'.
loop at alvdata into alvline where select = true.
perform delete_a_message.
endloop.
* refresh the list data
perform load_alvdata.
rs_selfield-refresh = true.
endif.
endif.
endif.
* process hotspots
when '&IC1'.
case rs_selfield-fieldname.
when 'FILENAME'.
submit ylo_newbreed_message_edit
with p_file = alvline-filename
with p_change = ' '
and return.
when 'LASTSTS'.
perform display_messages.
endcase.
endcase.
endform. "alv_command_handler
i cut a lot fo code out of this, so it may be missing some endif or whatever, but as you can see, you check the ok code, and if it matches your GUIstatus button, you loop over the internal table and process the data
sorry for the long reply. i hope it helps
2009 Jan 21 7:52 PM
@David
How do we create GUI status and assign OK_CODE's to it?
Thanks
Kumar.
2009 Sep 16 6:18 PM
over your program put the mouse over and press the right, the you can see create then you have the gui status