Application Development and Automation 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: 
Read only

how to program a 'select all' button ?

santanunayek
Explorer
0 Likes
4,308

hi.

      i am creating an interactive list report using checkbox.

     the basic list output for SY-LSIND = 1 in the following image

 

    

        i want to have a SELECT ALL button to select all the checkbox at a time.

        plz help me with the code on how to select all the checkbox at a time..

       thank you..

8 REPLIES 8
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,053

In your PF status add a button for select all in application in toolbar. It will be display. Once it is click in your user command Loop at OUTPUT table and pass value X to this chekcbox field

Nabheet

Read only

philipdavy
Contributor
0 Likes
3,053

Hi Santanu,

Refer the below given link. Seems like similar scenario as that of yours.

https://scn.sap.com/thread/733049

Regards,

Philip.

Read only

Former Member
0 Likes
3,053

1. First set the GUI Status in PBO.

2. In the menu painter, for that GUI, create select all button with fcode say '&SEL'.

3. In the ALV FM, have a user command module,

3. In the user command module, if r_ucomm = '&SEL'.

loop through the data table, and set checkbox = 'X' for all row.

4. Dont forget to refresh ALV using rs_selfield-refresh = 'X'.

You will get your desired output.

Read only

muthuchemca
Explorer
0 Likes
3,053

Hello Santanu,

Please refer below std program.

BCALV_EDIT_05

Read only

Former Member
0 Likes
3,053

You have to add a button for select all in your PF status & when that button is clicked (sy-ucomm),

loop your internal table & make checkbox eq 'X'..

check this thread

Read only

sivaganesh_krishnan
Contributor
0 Likes
3,053

Hi santanu,

Check the following code, create a button select all in application toolbar of pf status.

TABLES: mara,makt.

TYPES: BEGIN OF ty_mara,

         matnr TYPE  matnr,    "Material Number

         ersda TYPE  ersda,    "Created On

         ernam TYPE  ernam,    "Name of Person who Created the Object

        END OF ty_mara,

        BEGIN OF ty_makt,

         matnr TYPE  matnr,    "Material Number

         spras TYPE  spras,    "Language Key

         maktx TYPE  maktx,    "Material Description (Short Text)

        END OF ty_makt.

DATA: it_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 0,

       wa_mara TYPE ty_mara,

       it_makt TYPE STANDARD TABLE OF ty_makt INITIAL SIZE 0,

       wa_makt TYPE ty_makt,

       lv_matnr TYPE matnr,

     c1  .

DATA: SD_BOOL TYPE wdy_boolean,

        PS_BOOL type wdy_boolean.

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

SELECT-OPTIONS: s_matnr FOR mara-matnr.

SELECTION-SCREEN: END OF BLOCK b1.

AT SELECTION-SCREEN.

   IF s_matnr IS NOT INITIAL.

     SELECT SINGLE matnr

     FROM mara

     INTO lv_matnr

     WHERE matnr IN s_matnr.

     IF sy-subrc NE 0.

       MESSAGE: 'Material Number does not exist' TYPE'E'.

     ENDIF.

   ENDIF.

START-OF-SELECTION.

   SELECT matnr

          ersda

          ernam

  FROM  mara

  INTO TABLE it_mara

  WHERE matnr IN s_matnr.

   IF sy-subrc EQ 0.

     SORT it_mara BY matnr.

   ENDIF.

   SET PF-STATUS 'CHK'.

AT USER-COMMAND.

   CASE sy-ucomm.

     WHEN 'DISPLAY'.

       DATA ln TYPE i.

   DESCRIBE LIST NUMBER OF LINES ln.

   DO ln TIMES.

     READ LINE sy-index FIELD VALUE c1 .

     IF c1 = 'X'.

       SELECT matnr

              spras

              maktx

    FROM  makt

    INTO TABLE it_makt

    WHERE matnr = wa_mara-matnr.

       IF sy-subrc EQ 0.

         SORT it_makt BY matnr.

       ENDIF.

       IF it_makt IS NOT INITIAL.

         LOOP AT it_makt INTO wa_makt.

           WRITE: / wa_makt-matnr,

                    wa_makt-spras,

                    wa_makt-maktx.

         ENDLOOP.

       ENDIF.

     ENDIF.

   ENDDO.

       WHEN 'EXIT'.

       message:'Are you sure' type'I'.

       LEAVE LIST-PROCESSING.

     WHEN 'SELECTALL'  .

  IF c1 IS INITIAL.

LOOP AT it_mara INTO wa_mara.

    c1 = 'X'.

       WRITE: / c1 as CHECKBOX  ,wa_mara-matnr,

                wa_mara-matnr,

                wa_mara-ersda,

                wa_mara-ernam.

       HIDE wa_mara-matnr.

     ENDLOOP.

.

  ENDIF.

     WHEN OTHERS.

       endcase.

END-OF-SELECTION.

   IF it_mara IS NOT INITIAL.

     LOOP AT it_mara INTO wa_mara.

       WRITE: / c1 as CHECKBOX  ,wa_mara-matnr,

                wa_mara-matnr,

                wa_mara-ersda,

                wa_mara-ernam.

       HIDE wa_mara-matnr.

     ENDLOOP.

   ENDIF.

AT LINE-SELECTION.

   SELECT matnr

          spras

          maktx

   FROM  makt

   INTO TABLE it_makt

   WHERE matnr = wa_mara-matnr.

   IF sy-subrc EQ 0.

     SORT it_makt BY matnr.

   ENDIF.

   IF it_makt IS NOT INITIAL.

     LOOP AT it_makt INTO wa_makt.

       WRITE: / wa_makt-matnr,

                wa_makt-spras,

                wa_makt-maktx.

     ENDLOOP.

   ENDIF.

Read only

santanunayek
Explorer
0 Likes
3,053

thanks for all your support..

but the fact is ..i am creating these checkbox at the output list only..it's not a internal table or db field. my program is as follows:

LOOP AT IT_01 INTO WA_01.                                   " IT_01 is the internal table

      WRITE:/1'|', CHK AS CHECKBOX    , 7'|',

            8(18)  WA_01-MATNR COLOR 2,26'|',

           27(10)  WA_01-ERSDA COLOR 3 INTENSIFIED OFF,40'|'.

      HIDE WA_01-MATNR.

  ENDLOOP.

plz help me if u can..thanks

Read only

0 Likes
3,053

check my above program buddy.. this will solve the issue.. try executing it ..

Regards,

Sivaganesh