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: 

problem for disabling checkbox in ALV

Former Member
0 Kudos

hi,

I'm facing a problem to disable some checkbox in my ALV.

I have used ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.

to disable somes (including the checkbox).

The cell is well disabled but I can always check the checkbox in the cell.

I used 'REUSE_ALV_LVC' for alv dispplay.

Anyone could help me?

Tks in advance

Yimin

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Check this

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/disableorEnableInputfieldsConditionallyIn+ALV

8 REPLIES 8

Former Member
0 Kudos

Hi ,

try using CL_GUI_FRONTEND_SERVICES class, and TABLE_FOR_FIRST_DISPLAY method

Regards,

Chinna

former_member188685
Active Contributor
0 Kudos

Check this

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/disableorEnableInputfieldsConditionallyIn+ALV

0 Kudos

I got this problem because the column is set to 'Hotspot'.

The cl_gui_alv_grid=>mc_style_disabled doesn't work in this case.

How can I disable the hotspot of a single cell?

rgds

Yimin

0 Kudos

WHY are you using hotspot for checkbox, you can use directly without using hotspot.

0 Kudos

Vijay,

If I disable the hotspot, then I need to double -click the checkbox in ordre to check it.

it's not what I wait...

0 Kudos

I am not sure this is what you are looking for ..Just check this sample code..

REPORT zalv_edit.
TYPE-POOLS: slis.
*- Fieldcatalog
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: x_fieldcat TYPE lvc_s_fcat.
DATA: x_layout TYPE lvc_s_layo.
"{ FOR DISABLE
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
"} FOR DISABLE
DATA: BEGIN OF it_vbap OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
check(1),
style TYPE lvc_t_styl, "FOR DISABLE
END OF it_vbap.
DATA: ls_outtab LIKE LINE OF it_vbap.
SELECT vbeln
posnr
UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_vbap
FROM vbap.

DATA:l_pos TYPE i VALUE 1.
CLEAR: l_pos.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'CHECK'.
x_fieldcat-fieldname = 'CHECK'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
*x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
x_fieldcat-outputlen = '10'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'VBELN'.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
*x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '10'.
x_fieldcat-ref_field = 'VBELN'.
x_fieldcat-ref_table = 'VBAK'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'POSNR'.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
*x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '5'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
"{FOR DISABLE HERE 6ROW IS DISABLED
LOOP AT it_vbap.
  CLEAR : lt_edit, ls_edit.
  IF sy-tabix NE 6.
    ls_edit-style2 = cl_gui_alv_grid=>mc_style_enabled.

    ls_edit-style = cl_gui_alv_grid=>mc_style_hotspot.
  ELSE.
    ls_edit-style2 = cl_gui_alv_grid=>mc_style_disabled.

    ls_edit-style = cl_gui_alv_grid=>mc_style_hotspot_no.
  ENDIF.
  ls_edit-fieldname = 'CHECK'.
  ls_edit-style3 = space.
  ls_edit-style4 = space.
  ls_edit-maxlen = 5.
  INSERT ls_edit INTO TABLE lt_edit.
  INSERT lines of lt_edit INTO TABLE ls_outtab-style.
  MODIFY it_vbap INDEX sy-tabix FROM ls_outtab TRANSPORTING
  style .
  CLEAR ls_outtab.
ENDLOOP.
x_layout-stylefname = 'STYLE'.
x_layout-no_rowmark = 'X'.
"} UP TO HERE
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_callback_program      = sy-repid
    is_layout_lvc           = x_layout
    i_callback_user_command = 'USER_COMMAND'
    it_fieldcat_lvc         = it_fieldcat
  TABLES
    t_outtab                = it_vbap[]
  EXCEPTIONS
    program_error           = 1
    OTHERS                  = 2.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->UCOMM      text
*      -->SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield.

  BREAK-POINT.
  CASE ucomm.
      WHEN'&IC1'.

  ENDCASE.
ENDFORM.                    "user_command

This will Disable the Hotspot and Edit option also.

Check it once and get back if you have any issues

0 Kudos

ls_edit-style = cl_gui_alv_grid=>mc_style_hotspot_no.

That's what I'm looking for...

Tks Vijay!

Former Member
0 Kudos

Hi yimin,

You can try the following

This will stop the editable cells of your alv from accepting the input.

call method g_grid->set_ready_for_input

exporting

i_ready_for_input = 0.

Regards,

Kaushik.