Skip to Content
avatar image
Former Member

Disable Few Checkboxes in ALV using REUSE_ALV_GRID_DISPLAY

Hi All,

Here I am trying to disable few checkboxes based on internal table data using the

FM 'REUSE_ALV_GRID_DISPLAY' but it's not working. I have written the below code.

READ TABLE gt_ret_status WITH KEY pernr = gt_0019-pernr.
IF sy-subrc EQ 0 AND gt_ret_status-status NE '04'.
gt_data-flag = '2'.
ELSE.
gt_data-flag = ' '.
ENDIF.

gs_layout-box_fieldname = 'FLAG'.
gs_layout-box_tabname = 'GT_DATA'.
gs_layout-edit_mode = 'X'.

I am getting the output as below.

Please suggest me on this

Thanks in advance.

check-box.png (2.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • I can see that the checkboxes are disabled on your screenshot. What is your question?

    By the way, "box" fields are for the big "square" button on the left of the rows. They are not for checkbox fields.

  • Get RSS Feed

4 Answers

  • Dec 23, 2016 at 02:05 PM

    SCN code galery has an example of using checkboxes with the REUSE_ALV_GSRID_DISPLAY function module:

    SCN Code Gallery - ALV with checkboes

    But I would recommend you look into the SALV Factory method for a much easier implementation of checkboxes:

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 31, 2016 at 09:38 AM

    Hi,

    If you want to disable Checkboxes according to data in your internal table, you will have to use styles.

    Add a field with type lvc_t_style in your final table. In your table wherever you want them disabled, append line passing fieldname and style cl_gui_alv_grid=>mc_style_disabled or cl_gui_alv_grid=>mc_style_enabled. Also pass your style fieldname in your stylefname field of your layout.

    Eg.

    types : begin of ty_final,

    include structure mara.

    checkbox type c,

    styl type lvc_t_style,

    end of ty_final.

    data : lt_final type table of ty_final

    .

    select * from mara upto 100 rows into table lt_final.

    loop at lt_final assigning field-symbol(<fs_mara>).

    if <condition>.

    ls_styl-fieldname = CHECKBOX'.
    ls_styl-style = cl_gui_alv_grid=>mc_style_enabled.

    endif.
    APPEND ls_styl TO ls_final-styl.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 31, 2016 at 09:38 AM

    Hi,

    If you want to disable Checkboxes according to data in your internal table, you will have to use styles.

    Add a field with type lvc_t_style in your final table. In your table wherever you want them disabled, append line passing fieldname and style cl_gui_alv_grid=>mc_style_disabled or cl_gui_alv_grid=>mc_style_enabled. Also pass your style fieldname in your stylefname field of your layout.

    Eg.

    types : begin of ty_final,

    include structure mara.

    checkbox type c,

    styl type lvc_t_style,

    end of ty_final.

    data : lt_final type table of ty_final,

    ls_styl type lvc_s_style.

    select * from mara upto 100 rows into table lt_final.

    loop at lt_final assigning field-symbol(<fs_mara>).

    if <condition>.

    ls_styl-fieldname = CHECKBOX'.
    ls_styl-style = cl_gui_alv_grid=>mc_style_enabled.

    APPEND ls_styl TO ls_final-styl.

    endif.

    endloop.

    Pass : gs_layo-stylefname = 'STYL' in your layout.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 02, 2017 at 06:56 AM

    Hi,

    I found this scn comment very useful.

    ''The key momentums are the next:

    - you have to add a new column (1 char length) to your internal table, you are displaying in alv (f.e.: mark(1) TYPE c )

    - while you are filling the ALV table, you have to use the WRITE ... AS CHECKBOX statement.

    F.e.: DATA: MARKFIELD(1) TYPE C VALUE 'X'.

    ...

    WRITE MARKFIELD AS CHECKBOX. "checkbox selected

    MARKFIELD = SPACE.

    WRITE MARKFIELD AS CHECKBOX. "deselected

    WRITE MARKFIELD AS CHECKBOX INPUT OFF. "deselected, protected

    - to capture, a checkbox is checked or not, oyu have to use the ALV's user command. Here you have to loop on your output table and check if the mark field is empty or it has an 'X' in it.''

    Comment by Former Member, fellow scn member.

    Although this method only worked for me while printing a Classical report.

    Add comment
    10|10000 characters needed characters exceeded