对于ALV LVC 单元格的控制

 需求是:当数据不符合条件时,不可编辑,反之,可编辑

 

主要实现的技术:  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

 

代码如下:

 

" 数据声明 显示ALV数据 data: begin of i_data OCCURS 0, ... bdmng LIKE resb-bdmng, field_style TYPE lvc_t_styl, "FORDISABLE “ALV LVC END OF i_data. "ALV设置声明 DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE. DATA: it_fieldcat1 TYPE lvc_t_fcat, wa_fieldcat1 TYPE lvc_s_fcat, gd_layout TYPE lvc_s_layo, gd_repid LIKE sy-repid, it_sort TYPE lvc_t_sort, wa_sort TYPE lvc_s_sort. DATA: it_events TYPE slis_t_event, wa_events IKE LINE OF it_events. START-OF-SELECTION. "获取数据 ... loop at i_data. if i_data-bdmng < 0. ls_stylerow-fieldname = 'BDMNG' . ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. "不可编辑状态 APPEND ls_stylerow TO i_data-field_style. endif. modify i_data. endloop. PERFORM sub_build_fieldcatalog. "字段定义 PERFORM SUB_LAYOUT. "布局定义 PERFORM SUB_SORT. "排序 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = gd_repid i_callback_pf_status_set = 'SUB_STATUS_SET' i_callback_user_command = 'SUB_USER_COMMAND' i_callback_html_top_of_page = 'TOP_OF_HTML_PAGE' is_layout_lvc = gd_layout it_fieldcat_lvc = it_fieldcat1 it_sort_lvc = it_sort " it_events = it_events i_html_height_top = 28 i_save = 'X' TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2. FORM sub_build_fieldcatalog . "字段定义 REFRESH it_fieldcat1 . CLEAR wa_fieldcat1 . wa_fieldcat1-fieldname = 'BDMNG'. wa_fieldcat1-scrtext_m = ''. wa_fieldcat1-edit = 'X'. wa_fieldcat1-col_pos = 5. wa_fieldcat1-outputlen = 15. wa_fieldcat1-just = 'C'. wa_fieldcat1-ref_table = 'RESG'. APPEND wa_fieldcat1 TO it_fieldcat1. ... ENDFORM. FORM SUB_LAYOUT. "布局设置 gd_layout-stylefname = 'FIELD_STYLE'. gd_layout-zebra = 'X'. gd_layout-box_fname = 'SEL'. gd_layout-info_fname = 'COLOR'. gd_repid = sy-repid. ENDFORM. FORM SUB_SORT. "排序 CLEAR wa_sort. wa_sort-spos = '8'. wa_sort-fieldname = 'LGOBE'. wa_sort-up = 'X'. wa_sort-group = ''. wa_sort-subtot = 'X'. APPEND wa_sort TO it_sort. CLEAR wa_sort. ENDFORM. FORM sub_status_set USING p_extab TYPE slis_t_extab. "按钮 SET PF-STATUS ''. ENDFORM. FORM sub_user_command USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield. "按钮出发事件 CASE ucomm . WHEN ''. ENDCASE. CLEAR ucomm. ENDFORM. FORM top_of_html_page USING p_cl_dd TYPE REF TO cl_dd_document. "html 标题 * 定义缓冲区变量 DATA: m_p TYPE i , m_buffer TYPE string , l_name1 LIKE t001w-name1, text1(255) TYPE c. * 开始输出表头标题 CONCATENATE '<HTML><CENTER><H2>' '' '</H2></CENTER></HTML>' INTO m_buffer. CALL METHOD p_cl_dd->html_insert EXPORTING contents = m_buffer CHANGING position = m_p. LOOP AT XXX. CONCATENATE 'XXX' INTO text1 SEPARATED BY space. CALL METHOD p_cl_dd->add_text( text = text1 ). CALL METHOD p_cl_dd->add_gap( width = 20 ). CALL METHOD p_cl_dd->new_line. ... ENDLOOP. ENDFORM.

你可能感兴趣的:(对于ALV LVC 单元格的控制)