Checkbox alv Reports enable and disable checkbox behalf of condition
Checkbox enable and disable behalf of condition some time required to enable and disable checkbox so here simple please of code help you to checkbox enable and disable
REPORT zcheckbox.
INCLUDE zcheckbox_top.
INCLUDE zcheckbox_sel.
INCLUDE zcheckbox_sub.
INITIALIZATION.
START-OF-SELECTION.
PERFORM get_data.
PERFORM f_catalog.
PERFORM check_box_disable.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_check,
id TYPE integer,
name TYPE char40,
order TYPE char40,
box TYPE c,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF ty_check.
DATA: gt_fcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
gs_fcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
DATA: gt_final TYPE STANDARD TABLE OF ty_check,
gs_final TYPE ty_check.
FORM get_data .
gs_final-id = '1'.
gs_final-name = 'dev'.
gs_final-order = 'open'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
gs_final-id = '2'.
gs_final-name = 'amit'.
gs_final-order = 'open'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
gs_final-id = '3'.
gs_final-name = 'disha'.
gs_final-order = 'close'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form F_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_catalog .
gs_fcat-col_pos = '1'.
gs_fcat-fieldname = 'BOX'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-checkbox = 'X'.
gs_fcat-edit = 'X'.
gs_fcat-scrtext_m = 'Selection'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '2'.
gs_fcat-fieldname = 'ID'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-scrtext_m = 'Employee ID'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '3'.
gs_fcat-fieldname = 'NAME'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-scrtext_m = 'Employee Name'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '4'.
gs_fcat-fieldname = 'ORDER'.
gs_fcat-tabname = 'gt_final'.
gs_fcat-scrtext_m = 'ORDER TYPE'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
ENDFORM. " F_CATALOG
*&---------------------------------------------------------------------*
*& Form CHECK_BOX_DISABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM check_box_disable .
gd_layout-stylefname = 'FIELD_STYLE'.
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
LOOP AT gt_final INTO gs_final.
IF gs_final-order EQ 'close'.
ls_stylerow-fieldname = 'BOX' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO gs_final-field_style.
MODIFY gt_final FROM gs_final.
ENDIF.
ENDLOOP.
ENDFORM. " CHECK_BOX_DISABLE
*&---------------------------------------------------------------------*
*& Form DISPALY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM dispaly_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = gt_fcat
i_save = 'X'
TABLES
t_outtab = gt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " DISPALY_DATA
REPORT zcheckbox.
INCLUDE zcheckbox_top.
INCLUDE zcheckbox_sel.
INCLUDE zcheckbox_sub.
INITIALIZATION.
START-OF-SELECTION.
PERFORM get_data.
PERFORM f_catalog.
PERFORM check_box_disable.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_check,
id TYPE integer,
name TYPE char40,
order TYPE char40,
box TYPE c,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF ty_check.
DATA: gt_fcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
gs_fcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
DATA: gt_final TYPE STANDARD TABLE OF ty_check,
gs_final TYPE ty_check.
FORM get_data .
gs_final-id = '1'.
gs_final-name = 'dev'.
gs_final-order = 'open'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
gs_final-id = '2'.
gs_final-name = 'amit'.
gs_final-order = 'open'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
gs_final-id = '3'.
gs_final-name = 'disha'.
gs_final-order = 'close'.
APPEND gs_final TO gt_final.
CLEAR gs_final.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form F_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_catalog .
gs_fcat-col_pos = '1'.
gs_fcat-fieldname = 'BOX'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-checkbox = 'X'.
gs_fcat-edit = 'X'.
gs_fcat-scrtext_m = 'Selection'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '2'.
gs_fcat-fieldname = 'ID'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-scrtext_m = 'Employee ID'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '3'.
gs_fcat-fieldname = 'NAME'.
gs_fcat-tabname = 'GT_FINAL'.
gs_fcat-scrtext_m = 'Employee Name'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-col_pos = '4'.
gs_fcat-fieldname = 'ORDER'.
gs_fcat-tabname = 'gt_final'.
gs_fcat-scrtext_m = 'ORDER TYPE'.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
ENDFORM. " F_CATALOG
*&---------------------------------------------------------------------*
*& Form CHECK_BOX_DISABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM check_box_disable .
gd_layout-stylefname = 'FIELD_STYLE'.
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
LOOP AT gt_final INTO gs_final.
IF gs_final-order EQ 'close'.
ls_stylerow-fieldname = 'BOX' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO gs_final-field_style.
MODIFY gt_final FROM gs_final.
ENDIF.
ENDLOOP.
ENDFORM. " CHECK_BOX_DISABLE
*&---------------------------------------------------------------------*
*& Form DISPALY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM dispaly_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = gt_fcat
i_save = 'X'
TABLES
t_outtab = gt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " DISPALY_DATA
Comments
Post a Comment