Application Development 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: 

To activate/deactivate checkbox in ALV grid report

Former Member
0 Kudos

Hi All,

I am trying to create an ALV Grid that contains check-box as column fields. I am able to either activate or deactivate all the check-boxes in the entire column. But, I need to keep only certain check-boxes for editing based on certain conditions. The other check-boxes in the column should be deactivated for editing by the user. Any help is appreciated.

-Dinesh

4 REPLIES 4

Former Member
0 Kudos

Hi dinesh,

Try this:

DATA: ls_event_exit TYPE slis_event_exit,

lt_event_exit TYPE slis_event_exit OCCURS 1.

ls_event_exit-after = 'X'.

APPEND ls_event_exit TO lt_event_exit.

PERFORM field_attributes.

FORM field_attributes .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

LOOP AT itab_data INTO wa_data.

IF wa_data-status NE c_status_p. "Condiction to enable/disabled

ls_stylerow-fieldname = 'CHECK' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. "set field to disabled

APPEND ls_stylerow TO wa_data-field_style.

MODIFY itab_data FROM wa_data.

ENDIF.

ENDLOOP.

ENDFORM.

Hope this information is help to you.

Regards,

José

0 Kudos

Hi Jose,

Thanks for ur reply.

Can u provide me code for Resue_alv_grid_display with checkbox disable & enable in output.

Regards,

Dinesh

0 Kudos

Hi dinesh babu ,

In this example, i use 'REUSE_ALV_GRID_DISPLAY_LVC'

FORM display_alv .

DATA: ls_event_exit TYPE slis_event_exit,

lt_event_exit TYPE slis_event_exit OCCURS 1.

DESCRIBE TABLE itab_data LINES lv_cont.

PERFORM layout_build USING gs_layout.

PERFORM eventtab_build USING gt_events[].

PERFORM comment_build USING gt_lheader[].

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'ZHRESS_FORMACION_ALV'

i_client_never_display = 'X'

i_bypassing_buffer = 'X'

CHANGING

ct_fieldcat = gt_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT gt_fieldcat INTO ls_fcat.

  • Active check field

IF ls_fcat-fieldname EQ 'CHECK'.

ls_fcat-checkbox = 'X'.

ls_fcat-edit = 'X'.

ls_fcat-fix_column = 'X'.

ls_fcat-reptext = 'Check'.

ENDIF.

PERFORM field_attributes.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

  • i_background_id = 'ALV_BACKGROUND'

i_callback_program = g_repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = gs_layout

it_fieldcat_lvc = gt_fieldcat[]

i_save = g_save

is_variant = g_variant

it_events = gt_events[]

it_event_exit = lt_event_exit

i_default = 'X'

TABLES

t_outtab = itab_data.

ENDFORM. " DISPLAY_ALV

FORM field_attributes .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

LOOP AT itab_data INTO wa_data.

IF wa_data-status NE c_status_p. " Condition for enable / disable check

ls_stylerow-fieldname = 'CHECK' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. "set field to disabled

APPEND ls_stylerow TO wa_data-field_style.

MODIFY itab_data FROM wa_data.

ENDIF.

ENDLOOP.

ENDFORM.

Regards,

José

Edited by: Jose Luzardo on Oct 6, 2009 3:37 PM

0 Kudos

Hi dinesh babu, this is the missing portion

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA: lv_return TYPE bapireturn1.

DATA:ref_grid TYPE REF TO cl_gui_alv_grid.

RANGES: r_code FOR zhress_formacion-uname.

r_code-sign = 'I'.

r_code-option = 'EQ'.

r_code-low = '&REFRESH'.

APPEND r_code.

r_code-sign = 'I'.

r_code-option = 'EQ'.

r_code-low = '&ALL'.

APPEND r_code.

IF ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

ENDIF.

IF NOT ref_grid IS INITIAL.

CALL METHOD ref_grid->check_changed_data.

ENDIF.

Regards ,

José

Edited by: Jose Luzardo on Oct 6, 2009 3:45 PM