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_grid
IMPORTING e_fieldname
es_row_no
er_event_data
sender .
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 maRA
INNER JOIN makt ON mara~matnr = makt~matnr
UP TO 10 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'HIT_FIELD'
value_org = 'S'
TABLES
value_tab = lt_f4
return_tab = lt_ret_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 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_con
EXPORTING
container_name = 'CONTORL'.
CREATE OBJECT go_alv
EXPORTING
I_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_fields
EXPORTING
it_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_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gt_data
it_fieldcatalog = gt_fieldcat.
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1481974.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!