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

Select-ALL-Checkbox-1

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.


8 Comments

  1. HOW TO UNCHECK THE SELECTED CHECKBOXES AFTER -EXECUTING THE PROGRAM , CHECKING THE OUTPUT AND THEN AFTER PRESSING F3 TO GO BACK TO THE SELECTION SCREEN WHERE I HAVE SELECTED THE REQUIRED CHECKBOXES

  2. TABLES : mara , marc.
    DATA :BEGIN OF it_mara OCCURS 0,
    matnr TYPE matnr,
    ersda TYPE ersda,
    ernum TYPE ernam,
    END OF it_mara.

    DATA : BEGIN OF it_marc OCCURS 0,
    matnr TYPE matnr,
    pstat TYPE pstat,
    END OF it_marc.

    DATA : BEGIN OF it_join OCCURS 0,
    matnr TYPE matnr,
    ersda TYPE ersda,
    ernum TYPE ernum,
    matrn TYPE matnr,
    werks TYPE werks,
    pstat TYPE pstat,
    END OF it_join.

    SELECT-OPTIONS: s_matnr FOR it_mara-matnr.
    PARAMETERS : c1 AS CHECKBOX DEFAULT ‘X’,
    c2 AS CHECKBOX.

    START-OF-SELECTION.
    IF c1 = ‘X’ AND c2 = ”.
    SELECT matnr
    ersda
    ernam FROM mara INTO TABLE it_mara
    WHERE matnr IN s_matnr.

    LOOP AT it_mara.
    WRITE : / it_mara-matnr,
    it_mara-ersda,
    it_mara-ernum.
    ENDLOOP.

    ELSEIF c2 = ‘X’ AND c1 = ”.
    SELECT matnr
    pstat FROM marc INTO TABLE it_marc
    WHERE matnr IN s_matnr.

    LOOP AT it_marc.
    WRITE :/ it_marc-matnr,
    it_marc-pstat.
    ENDLOOP.

    ELSEIF c1 = ‘X’ AND c2 = ‘X’.
    SELECT t1~matnr
    t1~ersda
    t1~ernam
    t2~matnr
    t2~pstat
    FROM mara AS t1 INNER JOIN marc AS t2
    ON t1~matnr = t2~matnr
    INTO TABLE it_join
    UP TO 5 ROWS.
    ENDIF.
    LOOP AT it_join.
    WRITE : / it_join-matnr,
    it_join-ersda,
    it_join-ernum,
    it_join-matnr,
    it_join-pstat.
    ENDLOOP.

Comments are closed.