欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

FM ALV 可编辑下拉框

程序员文章站 2022-04-12 10:34:37
...
ALV FM : REUSE_ALV_GRID_DISPLAY_LVC
使用set_drop_down_table 方法
ALV结构增加 要显示Listbox的字段 举例:Listbox
fieldcat字段设置
fieldcat-fieldname = ‘Listbox’
fieldcat-edit = 'X'.
fieldcat-drdn_field = 'DD_HANDLE'.
fieldcat-drdn_hndl  = '1'.

*定义存储下拉列表的数据
DATA :gt_ddval TYPE lvc_t_drop,
      gw_ddval TYPE lvc_s_drop.
*EVENT
DATA: i_events  TYPE slis_t_event,
      wa_events TYPE slis_alv_event.    

  wa_events-name = 'CALLER_EXIT'.
  wa_events-form = 'SET_LIST'.
  APPEND wa_events TO i_events.

*设置下拉列表,Grid和内表链接
*---------------------------------------------------------------------*
FORM set_list USING ls_caller_exit TYPE slis_data_caller_exit.
  DATA: o_grid TYPE REF TO cl_gui_alv_grid.
  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = o_grid.

  CALL METHOD o_grid->set_drop_down_table
    EXPORTING
      it_drop_down = gt_ddval.

ENDFORM.                    "CALLER_EXIT

*生成下拉列表
*---------------------------------------------------------------------*
FORM creat_dropdown_values.

  CLEAR gw_ddval.
  gw_ddval-handle = '1'.
  gw_ddval-value  = '测试1'.
  APPEND gw_ddval TO gt_ddval.
    CLEAR gw_ddval.
  gw_ddval-handle = '1'.
  gw_ddval-value  = '测试2'.
  APPEND gw_ddval TO gt_ddval.
    CLEAR gw_ddval.
  gw_ddval-handle = '1'.
  gw_ddval-value  = '测试3'.
  APPEND gw_ddval TO gt_ddval.
  
  ENDFORM.                    " creat_dropdown_values



相关标签: ABAP Listbox