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: 

Check box selection in ALV as dynamic

Former Member
0 Kudos

Gurus,

I have a check box in my alv display. User want to check the check box for some conditions only. If the condition fails the check box should be non editable while alv display for the users ..

If condition = pass.

Edit = u2018 X u2018.

Else.

EDIT = u2018 u2018.

Endif.

Refer is there is any example codes exists u2026

Thanks in advance..

Edited by: sridhar arjunan on Sep 17, 2008 1:37 PM

2 REPLIES 2

dhorions
Contributor
0 Kudos

Misread th question, my answer was totally wrong. Sorry

Edited by: Dries Horions on Sep 17, 2008 10:08 AM

former_member188685
Active Contributor
0 Kudos

Follow the wiki to understand indetail.

https://wiki.sdn.sap.com/wiki/display/Snippets/DisableorEnableInputfieldsConditionallyIn+ALV

Check this sample code..i modifed the code a little for checkbox

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-seltext = 'CHECK'.
x_fieldcat-fieldname = 'CHECK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-checkbox = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '5'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-seltext = 'VBELN'.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
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-seltext = 'POSNR'.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
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
sy-tabix = 6.
ls_edit-fieldname = 'CHECK'.
ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 5.
INSERT ls_edit INTO TABLE lt_edit.
ls_edit-fieldname = 'VBELN'.
ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 10.
INSERT ls_edit INTO TABLE lt_edit.
ls_edit-fieldname = 'POSNR'.
ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 6.
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 .
x_layout-stylefname = 'STYLE'.
"} UP TO HERE
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_callback_program = sy-repid
    is_layout_lvc      = x_layout
    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.