SAPHub

Select All Checkbox option in the selection screen

This code shows how to check all/uncheck all checkboxes in one go on the selection screen instead of checking the checkboxes individually.If the user checks the Select All checkbox then all other checkboxes will be checked, similarly if the user unchecks the Select All checkbox then all other checkboxes will be unchecked.

*-------------------------------------------------------------

* Constants

*-------------------------------------------------------------

CONSTANTS: c_title(10) VALUE 'Options'.

*-------------------------------------------------------------

* Selection Screen

*-------------------------------------------------------------

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE v_name.

SELECTION-SCREEN: SKIP.

PARAMETERS: cb_all AS CHECKBOX USER-COMMAND uc.

SELECTION-SCREEN: SKIP.

PARAMETERS: cb_a AS CHECKBOX,

cb_b AS CHECKBOX,

cb_c AS CHECKBOX,

cb_d AS CHECKBOX,

cb_e AS CHECKBOX.

SELECTION-SCREEN: END OF BLOCK b1.

*-------------------------------------------------------------

* At Selection Screen Event

*-------------------------------------------------------------

AT SELECTION-SCREEN.

IF sy-ucomm = 'UC'.

IF cb_all = 'X'.

cb_a = cb_b = cb_c = cb_d = cb_e = 'X'.

ELSE.

Clear: cb_a, cb_b, cb_c, cb_d, cb_e.

ENDIF.

ENDIF.

*-------------------------------------------------------------

* Initialization

*-------------------------------------------------------------

INITIALIZATION.

v_name = c_title.

Selection Screen

Try check/uncheck the Select All checkbox observing the status of other checkboxes. Maintain Selection Texts to get the proper descriptions for the checkboxes on the selection screen.