ABAP - OOALV 单元格 F4实现
- FIELDCAT参数 F4AVAILABL赋值
gs_fieldcat-f4availabl = 'X'.
- 类的定义和实现
CLASS cl_event DEFINITION.PUBLIC SECTION.METHODS: handle_onf4 FOR EVENT onf4 OF cl_gui_alv_gridIMPORTING e_fieldnamees_row_noer_event_datasender .
ENDCLASS.CLASS cl_event IMPLEMENTATION.METHOD handle_onf4.DATA:ls_modi TYPE lvc_s_modi,lt_ret_tab TYPE TABLE OF ddshretval.FIELD-SYMBOLS <modtab> TYPE lvc_t_modi.IF e_fieldname = 'MATNR'. "需要自定义搜索的字段名READ TABLE gt_data TRANSPORTING NO FIELDS INDEX es_row_no-row_id.CHECK sy-subrc = 0.SELECT mara~matnr,makt~maktx INTO TABLE @DATA(lt_f4)FROM maRAINNER JOIN makt ON mara~matnr = makt~matnrUP TO 10 ROWS.CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGretfield = 'HIT_FIELD'value_org = 'S'TABLESvalue_tab = lt_f4return_tab = lt_ret_tabEXCEPTIONSparameter_error = 1no_values_found = 2OTHERS = 3.IF sy-subrc = 0.READ TABLE lt_ret_tab INTO DATA(lw_ret_tab) INDEX 1.IF sy-subrc = 0. "ls_modi-row_id = es_row_no-row_id.ls_modi-fieldname = e_fieldname.ls_modi-value = lw_ret_tab-fieldval.ASSIGN er_event_data->m_data->* TO <modtab>.APPEND ls_modi TO <modtab>.ENDIF.ENDIF.er_event_data->m_event_handled = 'X'.ENDIF.ENDMETHOD.ENDCLASS.
- 通过事件处理类的实例对象给OOALVDUI的实例对象设置注册事件
CREATE OBJECT go_conEXPORTINGcontainer_name = 'CONTORL'.CREATE OBJECT go_alvEXPORTINGI_parent = go_con.DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.CLEAR lt_f4.lt_f4-fieldname = 'MATNR'.lt_f4-register = 'X'.lt_f4-chngeafter = 'X'.APPEND lt_f4.CALL METHOD go_alv->register_f4_for_fieldsEXPORTINGit_f4 = lt_f4[].DATA(lo_event) = NEW cl_event( ).SET HANDLER lo_event->handle_onf4 FOR go_alv.CALL METHOD go_alv->set_table_for_first_displayEXPORTINGis_layout = gs_layoutCHANGINGit_outtab = gt_datait_fieldcatalog = gt_fieldcat.
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/503492.html
如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!