作者:C1_VISION | 来源:互联网 | 2023-09-16 18:06
一般在Dialog中用下面一个函数,显示下拉列表,本例以f4函数来实现的 |
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'P_LGORT' "对应屏幕的input框名称
VALUES = I_VALUES[]
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2.
PS:绘制屏幕时,设置下拉参数有两种:listbox;listbox with key
listbox with key 表示即使你的gui状态中不设置在下拉列表中显示key关键字,但他任然显示key
参数
VALUES,是一个内表结构,含2个字段(key,value),选择
listbox with key 时,感觉好像
key,value都进入input框了,但实际只有key传入了,可以debug验证
程序执行效果:
1.主程序代码
DATA: OK_CODE TYPE SY-UCOMM.
DATA: BEGIN OF ITAB OCCURS 0,
CARRNAME LIKE SCARR-CARRNAME,
END OF ITAB.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module CREATE_DROPDOWN_LIST INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CREATE_DROPDOWN_LIST INPUT.
REFRESH ITAB.
CLEAR ITAB.
ITAB-CARRNAME = '合格'.
APPEND ITAB.
ITAB-CARRNAME = '不合格'.
APPEND ITAB.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
RETFIELD = 'CARRNAME'
* PVALKEY = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
* DYNPROFIELD = ' '
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
VALUE_ORG = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
VALUE_TAB = ITAB
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
* EXCEPTIONS
* PARAMETER_ERROR = 1
* NO_VALUES_FOUND = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDMODULE. " CREATE_DROPDOWN_LIST INPUT
2.自定义屏幕100
screen 100中的work flow:
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
PROCESS ON VALUE-REQUEST.
FIELD LISTID MODULE CREATE_DROPDOWN_LIST.
layout:
PS:下拉框为什么含有空指?
因为非必输,必输就没有了。