在ALV界面添加下拉框

时间:2022-01-29 01:09:32

1.在alv界面表单属性中设置

if wa_fieldcat-fieldname = 'YC_MARK'.
             wa_fieldcat-edit = 'X'.
             wa_fieldcat-drdn_field = 'DD_HANDLE'.
             wa_fieldcat-drdn_hndl = '1'.
        endif.

2.给下拉框赋值

LTH_LIST-HANDLE = '1' .
  LTH_LIST-VALUE = 'N' .
  APPEND LTH_LIST TO TD_LIST.
  CLEAR LTH_LIST.
  LTH_LIST-HANDLE = '1' .
  LTH_LIST-VALUE = 'Y'.
  APPEND LTH_LIST TO TD_LIST.
  CLEAR LTH_LIST.

3.设置IT_events

data:lt_event type table of slis_alv_event,
      lw_event type slis_alv_event.

perform alv_fieldcat.

it_layout-cwidth_opt = 'X'.
  it_layout-box_fname = 'SEL'.

lw_event-name = 'CALLER_EXIT'.
   lw_event-form = 'SET_LIST'.
   append lw_event to lt_event.

call function 'REUSE_ALV_GRID_DISPLAY_LVC'
    exporting
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'PF_STATUS '
      i_callback_user_command  = 'USER_COMMAND'
      is_layout_lvc            = it_layout
      it_fieldcat_lvc          = it_fieldcat
      it_events                = lt_event
    tables
      t_outtab                 = gt_excel
    exceptions
      program_error            = 1
      others                   = 2.

4.将下拉框赋值给ALV界面字段

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      E_GRID              = LW_GRID.

CALL METHOD LW_GRID->SET_DROP_DOWN_TABLE
          EXPORTING

IT_DROP_DOWN       = TD_LIST.