ALV网格自定义F4帮助有效,但随后显示未找到帮助

时间:2019-02-27 10:19:01

标签: sap abap

我有一个程序,该程序显示可编辑的ALV网格,并为字段“否”提供了自定义F4帮助。显示F4帮助,并正确返回所选值。

enter image description here

但是,每次自定义F4帮助关闭后,都会打开另一个窗口,提示“没有可用的输入帮助”。

enter image description here

如何摆脱此补充弹出窗口?

谢谢。

这是我的代码:

CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    METHODS constructor.
    METHODS display.
    METHODS on_onf4
                  FOR EVENT onf4 OF cl_gui_alv_grid
      IMPORTING e_fieldname es_row_no e_fieldvalue.
    DATA: grid   TYPE REF TO cl_gui_alv_grid,
          spflis TYPE TABLE OF spfli.
ENDCLASS.

CLASS lcl_app IMPLEMENTATION.

  METHOD constructor.
    SELECT * FROM spfli INTO TABLE spflis.
    grid = NEW cl_gui_alv_grid(
        i_parent = cl_gui_container=>screen0 ).
    SET HANDLER on_onf4 FOR grid.
    grid->register_f4_for_fields(
        it_f4 = VALUE #( ( fieldname = 'CONNID' register = 'X' chngeafter = 'X' ) ) ).
  ENDMETHOD.

  METHOD display.
    DATA(fcat) = VALUE lvc_t_fcat(
        ( fieldname = 'CARRID' ref_table = 'SPFLI' )
        ( fieldname = 'CONNID' ref_table = 'SPFLI' f4availabl = 'X' ) ).
    grid->set_table_for_first_display(
        EXPORTING is_layout = VALUE #( edit = 'X' )
        CHANGING it_outtab = spflis
                 it_fieldcatalog = fcat
        EXCEPTIONS OTHERS = 4 ).
  ENDMETHOD.

  METHOD on_onf4.
    DATA return TYPE TABLE OF ddshretval.
    IF e_fieldname = 'CONNID'.
      SELECT DISTINCT connid FROM spfli INTO TABLE @DATA(connids).
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'CONNID'
          value_org       = 'S'
        TABLES
          value_tab       = connids
          return_tab      = return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc = 0 AND return IS NOT INITIAL.
        FIELD-SYMBOLS <modis> TYPE lvc_t_modi.
        ASSIGN er_event_data->m_data->* TO <modis>.
        <modis> = VALUE #( BASE <modis> ( row_id = es_row_no-row_id
            fieldname = e_fieldname 
            value = return[ 1 ]-fieldval ) ).
      ENDIF.
    ENDIF.
  ENDMETHOD.

ENDCLASS.

PARAMETERS dummy.

AT SELECTION-SCREEN OUTPUT.
  NEW lcl_app( )->display( ).

1 个答案:

答案 0 :(得分:2)

在F4方法处理程序中需要将标记er_event_data->m_event_handled设置为'X',以表明F4实际上是由自定义处理管理的,否则ALV网格会尝试显示标准F4(在我的情况下,没有标准的F4,因此没有弹出窗口。

首先在方法声明中添加ER_EVENT_DATA参数:

    METHODS on_onf4
                  FOR EVENT onf4 OF cl_gui_alv_grid
      IMPORTING e_fieldname es_row_no e_fieldvalue
                  er_event_data.

在方法ON_ONF4中,设置标志:

er_event_data->m_event_handled = 'X'.