我们通过工厂 来控制下面下拉框的值
首先 屏幕定义
代码:
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
PARAMETERS: r1 RADIOBUTTON GROUP g01 DEFAULT 'X' USER-COMMAND u1, " 生成条码
r2 RADIOBUTTON GROUP g01. " 查询条码
SELECTION-SCREEN ULINE.
PARAMETERS p_werks TYPE ztppr004-werks VISIBLE LENGTH 20 AS LISTBOX USER-COMMAND p1.
SELECT-OPTIONS s_zvbel1 FOR ztppr004-zvbel NO INTERVALS NO-EXTENSION MODIF ID sc1. " 生成条码
SELECT-OPTIONS s_zvbel2 FOR ztppr004-zvbel MODIF ID cx1. " 查询条码
SELECT-OPTIONS s_dispo FOR afko-dispo MODIF ID cx1. " mrp 控制者
PARAMETERS p_cj TYPE char20 VISIBLE LENGTH 20 AS LISTBOX .
SELECTION-SCREEN END OF BLOCK blk1.
这里我们 要给第一个下拉框 按钮代码 USER-COMMAND
首先设置 第一个下拉框的值
通过 AT SELECTION-SCREEN OUTPUT. 事件设置
DATA: vid TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
value-key = '1188'.
value-text = '天下工厂'(t73).
APPEND value TO list.
value-key = '1388'.
value-text = '必赏课工厂'(t74).
APPEND value TO list.
value-key = '2088'.
value-text = '南山工厂'(t75).
APPEND value TO list.
* value-key = '1102'.
* value-text = '图投工厂'.
* APPEND value TO list.
***调用下拉框赋值函数
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_WERKS'
values = list.
接下来如果第一个下拉框输入完值 给第二个下拉框赋值
这里我们通过 AT SELECTION-SCREEN.
判断第一个下拉框的判断按钮 代码 p1 这里判断的文本字母一定要大写
IF sy-ucomm = 'P1'.
CLEAR p_cj.
DATA: vid TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
IF p_werks = '2088'.
value-key = 'P03'.
value-text = 'IP车间'(t71).
APPEND value TO list.
CLEAR value.
value-key = 'P04'.
value-text = '转印车间'(t72).
APPEND value TO list.
CLEAR value.
***调用下拉框赋值函数
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_CJ'
values = list.
ELSEIF p_werks = '1188' OR p_werks = '1102'.
value-key = 'P09'.
value-text = 'IP车间'(t43).
APPEND value TO list.
value-key = 'P07'.
value-text = 'RB车间'(t44).
APPEND value TO list.
value-key = 'P06'.
value-text = 'MD车间'(t45).
APPEND value TO list.
* value-key = 'P2-5'.
* value-text = 'CROCS一次射出'(t46).
* APPEND value TO list.
***调用下拉框赋值函数
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_CJ'
values = list.
ELSEIF p_werks = '1388' .
value-key = 'P2-5'.
value-text = 'CROCS一次射出'(t46).
APPEND value TO list.
***调用下拉框赋值函数
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_CJ'
values = list.
ENDIF.
ENDIF.