实现上面的业务场景时,制作下拉列表。
PARAMETERS:p_list TYPE char1 AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_list.
PERFORM p_set_selection.
*&---------------------------------------------------------------------*
*& Form P_SET_SELECTION
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM p_set_selection .
TYPES :BEGIN OF ty,
col1 TYPE char3,
col2 TYPE char20,
END OF ty.
DATA itab TYPE TABLE OF ty.
itab = VALUE #(
( col1 = '1' col2 = '下拉列表1')
( col1 = '2' col2 = '下拉列表2' )
( col1 = '3' col2 = '下拉列表3')
).
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'COL1'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'COL1'
* STEPL = 0
window_title = 'WINDOW--TITLE'
* VALUE = ''
value_org = 'S' "C表示cell,S表示structure
* MULTIPLE_CHOICE = 'X'"多项选择,用于SELECT-OPTIONS
* DISPLAY = 'F'"C则只能显示,不能选择
callback_program = sy-repid
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = itab
* FIELD_TAB = FIELD_TAB
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
p_list. 会返回 col1 的值。