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

ALV user-command problem

Former Member
0 Likes
881

Pushbutton is there on Appication Toolbar.

ALV has First Column as checkboxes.

If user gonna click on that pushbutton it has to select all the checkboxes in eachrow of first column.

where I need to connect this functionality inside the Subroutine 'USER_COMMAND'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
    I_CALLBACK_PROGRAM                = W_REPID
    I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS'
    I_CALLBACK_USER_COMMAND           = <b>'USER_COMMAND'</b>


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 'SELECTALL'.
           loop at itab.
               itab-check = 'X'.
               modify itab index sy-tabix.
            endif.
     ENDCASE.

    P_SELFLD-REFRESH = 'X'.

ENDFORM.
7 REPLIES 7
Read only

Former Member
0 Likes
816

Hi,

After pressing the push button

Modify the internal table value for the check box column with 'X'

If you set the value as X it will automatically selects all the rows.

Reward if helpful.

Read only

Pawan_Kesari
Active Contributor
0 Likes
816

You don't have to code this functionality... there is select all and deselect all button available and that will work with your field .. just fill following fields in layout streucture

box_fieldname type slis_fieldname, " fieldname for checkbox

box_tabname type slis_tabname," tabname for checkbox

Read only

Former Member
0 Likes
816

I layout give Checkbox

or

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = '1'.

wa_fieldcat-fieldname = 'FLAG'.

wa_fieldcat-tabname = 'T_OUTPUT'.

wa_fieldcat-seltext_l = 'Flag'.

wa_fieldcat-Checkbox = 'X'.

wa_fieldcat-edit = 'X'.

  • wa_fieldcat-no_out = 'X'.

wa_fieldcat-outputlen = '10'.

APPEND wa_fieldcat TO t_fieldcat.

form user_command using r_ucomm type syucomm

ls_selfield type SLIS_SELFIELD.

Break-point.

case r_ucomm.

when 'EXEC'.

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 t_output where Flag = 'X'.

Read only

Former Member
0 Likes
817
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
    I_CALLBACK_PROGRAM                = W_REPID
    I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS'
    I_CALLBACK_USER_COMMAND           = <b>'USER_COMMAND'</b>


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 'SELECTALL'.
           loop at itab.
               itab-check = 'X'.
               modify itab index sy-tabix.
            endif.
     ENDCASE.

    P_SELFLD-REFRESH = 'X'.

ENDFORM.
Read only

Former Member
0 Likes
816

Hi ,

1. add one more field checkbox of length 1 to ur final internal tabel

2. in ur fieldcatalg add this line

wa_fcat-fieldname = 'CHECKBOx'.

wa_fcat-checkbox = 'X'.

wa_fcat-outputlen = '1'.

wa_fcat-col_pos = '1'.

append wa_fcat to it_fcat.

3.in ur layout , add this line

wa_layout-box_fieldname = 'CHECKBOX'.

4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

case p_ucomm.

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

when 'SAVE'.

  • write ur code her

<b>or fm ALV then follow this :</b>


TYPE-POOLS : slis.
 
 
*-------------- Data
 
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
 
*--------- Select Data
 
SELECT * FROM t001 INTO TABLE itab.
 
 
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
 
 
*---------------Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
 
 
 
*-------------------------------------------------
* CALL BACK FORM
*-------------------------------------------------
 
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
 
data : msg(100) type c.
 
LOOP AT itab.
if itab-flag = 'X'.
msg = sy-tabix.
condense msg.
concatenate itab-bukrs ' ' into msg
separated by space.
message msg type 'I'.
endif.
 
ENDLOOP.
 
ENDFORM. "ITAB_user_command

or check this blog :

/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers

<b>Reward pts for usefull answer :)</b>

Regards

Sathish

Read only

Former Member
0 Likes
816

hi,

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = repid

I_CALLBACK_PF_STATUS_SET = 'pf-status'

I_CALLBACK_USER_COMMAND = 'user_command'

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

Data sel1 type ref to cl_gui_alv_grid.

call method sel1->check_changed_data

CASE sy-ucomm.

WHEN '&SEL'.

loop at itab.

itab-check = 'X'.

modify itab index sy-tabix.

endif.

ENDCASE.

endform.

Read only

Former Member
0 Likes
816

Lucky,

there is a functionality already available for that,

you can give the <b>function code</b> for the button as <b>&ALL</b> to select all the checkboxes and

<b>&SAL</b> to deselect all the checkboxes in-order to gain ur functionality.

<b>Reward points if this helps,</b>

Kiran