SAP选择屏幕下拉框实现

DATA:vid TYPE vrm_id , "屏幕字段(可以是单个的I/O空间或者是Table Control中的一个单元格)
     list TYPE vrm_values,
     value LIKE LINE OF list.

PARAMETERS S_LSBOX TYPE c  AS LISTBOX VISIBLE LENGTH 20 DEFAULT '2'.     “选择条件字段

*初始化时下拉框赋值
INITIALIZATION.

AT SELECTION-SCREEN OUTPUT

REFRESH LIST .

VALUE-KEY = '1' . "这个就是变量P_LIST的值
VALUE-TEXT = 'ZPR0' . "这个是text
APPEND VALUE TO LIST .

VALUE-KEY = '2' .
VALUE-TEXT = 'ZB01' .
APPEND VALUE TO LIST .

VALUE-KEY = '3' .
VALUE-TEXT = 'ZB02' .
APPEND VALUE TO LIST .

**调用下拉框赋值函数
CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
        ID = 'S_LSBOX'    
        VALUES = LIST.

或者PBO中的module:

PARAMETERS P_ZSCRF TYPE c AS LISTBOX VISIBLE LENGTH 3 .

Module drop_down_list output.

  TYPE-POOLS vrm.
  DATA :"name TYPE vrm_id,
        List TYPE vrm_values,
        Value LIKE LINE OF list.
  Name = 'P_ZSCRF'. "屏幕上绑定的下拉框也是这个名字。
  REFRESH list.
  Value-key = '1'.
  Value-text = 'M'.
  APPEND value TO list.

  Value-key = '2'.
  Value-text = 'D'.
  APPEND value TO list.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = Name
      values = list.

ENDMODULE.                    "drop_down_list OUTPUT

 

posted @ 2019-07-24 18:05  犹冷  阅读(3381)  评论(0编辑  收藏  举报