Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Capture Checkbox Value in ALV Grid

Former Member
0 Kudos

Hi,

I want to capture the value of the Check-box(ticked or unticked)

on the ALV Grid Display and then delete the lines that are not ticked.

I am using normal ALV not OO ALV.

Please suggest how do I capture the value on the screen for the Check-Box.

Thanks

~ Payel

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos
report  zcheck_alv.
tables : sflight.
type-pools: slis.


data: begin of it_sflight occurs 0,
checkbox(1),
carrid like sflight-carrid,
connid like sflight-connid,
end of it_sflight.

data: wa_layout type slis_layout_alv.

*field catalog
data: it_fieldcatalog type slis_t_fieldcat_alv,
wa_fieldcatalog type slis_fieldcat_alv.

start-of-selection.
select carrid connid from sflight
into corresponding fields of table it_sflight.

end-of-selection.
clear it_fieldcatalog.
refresh it_fieldcatalog.

wa_fieldcatalog-fieldname = 'CHECKBOX'.
wa_fieldcatalog-outputlen = '3'.
wa_fieldcatalog-col_pos = '1'.
wa_fieldcatalog-seltext_m = 'Chk'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'CARRID'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'Carrid'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'CONNID'.
wa_fieldcatalog-outputlen = '10'.
wa_fieldcatalog-col_pos = '2'.
wa_fieldcatalog-seltext_m = 'Carrid'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.

call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = wa_layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcatalog
tables
t_outtab = it_sflight
exceptions
program_error = 1
others = 2.

form user_command using p_ucomm type sy-ucomm

p_selfld type slis_selfield.

case p_ucomm.
when '&DATA_SAVE'.  "based on your action
data ref1 type ref to cl_gui_alv_grid.
"For capturing the selected data
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref1.
call method ref1->check_changed_data.
loop at it_sflight where checkbox = 'X'.
delete it_sflight index sy-tabix.
endloop.
p_selfld-refresh = 'X'.
endcase.
endform. "user_command

Former Member
0 Kudos

Hi Payel,

In the ALV output internal table you can see 'X' in that corresponding field that are ticked. You can delete the lines from internal table where that field is empty

Any difficulty in doing that?

Cheers,

Kothand

0 Kudos

Hi,

The output internal table has 0 in the check-box field for all records.

I am assigning the output table to a field symbol and passing that to the REUSE_ALV_GRID_DISPLAY FM.

Please let me know how to capture the on-screen value.

Thanks,

~ Payel

0 Kudos

in the user command you need to call the Function to get the updated records to the internal table.

form user_command using p_ucomm type sy-ucomm
p_selfld type slis_selfield.
"{ from here...
 "For capturing the selected data
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref1.
call method ref1->check_changed_data.
" till this part }
case p_ucomm.
when '&DATA_SAVE'.  "based on your action
data ref1 type ref to cl_gui_alv_grid.

loop at it_sflight where checkbox = 'X'.
delete it_sflight index sy-tabix.
endloop.
p_selfld-refresh = 'X'.
endcase.
endform. "user_command