使用'VRM_SET_VALUES'函数在selection屏幕上建一个Combobox控件示例

report z.
type-pools: vrm.
data: it_val type vrm_values,
      w_line like line of it_val.
parameters p_bukrs like t001-bukrs as listbox
           visible length 25 obligatory.

initialization.
  select bukrs butxt from t001 into (w_line-key, w_line-text).
    append w_line to it_val.
    check p_bukrs is initial.
    p_bukrs = w_line-key.
  endselect.

at selection-screen output.
  call function 'VRM_SET_VALUES'
       exporting
            id     = 'P_BUKRS'
            values = it_val.

end-of-selection.
  write: / 'Company Code:', p_bukrs.
增补,屏幕列表(启明星提供)

REPORT YAOWEI_TEST_LIST .
DATA: OK_CODE LIKE SY-UCOMM.
*下拉列表相关定义
TYPE-POOLS VRM. "下拉列表使用的类型定义
DATA: SC_LIST TYPE vrm_id. "使用列表的字段名
DATA:it_list TYPE vrm_values. "使用列表的清单内容
DATA: wa_list LIKE LINE OF it_list.
"创建列表清单使用的工作区
"不能自己定义内表,一定要用VRM_VALUES.其他有2个字段:KEY AND TEXT

START-OF-SELECTION.
CALL SCREEN 100.
"或PARAMETERS: SC_LIST(20) AS LISTBOX VISIBLE LENGTH 10.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
* SET TITLEBAR 'xxx'.

DATA:F_NUM TYPE I.
F_NUM = 100000001.
REFRESH IT_LIST. "勿忘
DO 10 TIMES.
*F_NUM = F_NUM + 1.
WA_LIST-KEY = '100000000'.
*F_NUM = F_NUM + 1.
WA_LIST-TEXT = 'A'.
APPEND WA_LIST TO IT_LIST.
ENDDO.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'SC_LIST' "屏幕中的下拉菜单的NAME,下拉菜单选择LISTBOX
*WITH KEY 若选LISTBOX的话带不出KEY值
values = IT_LIST.
REFRESH IT_LIST.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE: OK_CODE.
WHEN: 'BACK'.
LEAVE TO SCREEN 0.
*WHEN: 'LIST_SEL'.
*MESSAGE 'LIST_SEL' TYPE 'I'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT




你可能感兴趣的:(工作,F#)