2006 Nov 28 3:45 AM
I am using REUSE_ALV_GRID_DISPLAY to display a list. In this list the first column is a check box.Some checkboxes are already checked. The user can select and unselect rows. In this ALV you can select severals rows with the checkbox.
How to know which rows have been selected
2006 Nov 28 3:54 AM
in the user command subroutine of ur function module
call function 'REUSE_ALV_GRID_DISPLAY'
.......................
i_callback_userc0mmand = 'USER_COMMAND'.
...................
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
case p_ucomm.
when 'SAVE'.
loop at itab where checkbox = 'X'.
endloop.
endcase.
2006 Nov 28 3:47 AM
hi,
chk this sample code.
REPORT ychatest. .
TABLES : sflight.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA : BEGIN OF it_sflight OCCURS 0,
checkbox(1),
carrid LIKE sflight-carrid,
END OF it_sflight.
*layout
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 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.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_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
*&---------------------------------------------------------------------*
FORM user_command USING p_ucomm TYPE sy-ucomm
p_selfld TYPE slis_selfield.
CASE p_ucomm.
WHEN '&DATA_SAVE'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
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
rgds
Anver
2006 Nov 28 3:54 AM
in the user command subroutine of ur function module
call function 'REUSE_ALV_GRID_DISPLAY'
.......................
i_callback_userc0mmand = 'USER_COMMAND'.
...................
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
case p_ucomm.
when 'SAVE'.
loop at itab where checkbox = 'X'.
endloop.
endcase.