https://blog.csdn.net/Fall_in_Lc/article/details/125684466
Block 是在屏幕上划分一个区域,对屏幕进行分块便于对功能进行区分
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN END OF BLOCK blk1.
WITH FRAME 就是显示整个区域的边框
TITLE TEXT 就是给整个区域命名。TEXT-001可以在文本元素里给整个BLOCK添加描述
PARAMETERS: p_xxxx RADIOBUTTON GROUP g1 DEFAULT ‘X’,
p_xxxx RADIOBUTTON GROUP g1.
有时还需要加上 USER-COMMAND 关键字用于获取用户的选择
有时候为了好看,我们会把单选框横着来做
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS p_xxx1 RADIOBUTTON GROUP g1 USER-COMMAND uc DEFAULT 'X'.
SELECTION-SCREEN CMMENT 2(8) TEXT-002 FOR FIELD p_xxx1.
SELECTION-SCREEN POSITION 14.
PARAMETERS p_xxx2 RDIOBUTTON GROUP g1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blk1.
PARAMETERS p_xxx AS CHECKBOX.
使用SELECT-OPTIONS 来做输入框
PARAMETERS: p_xxxx TYPE xxxx OBLIGATORY
p_xxxx TYPE xxxx OBLIGATORY DEFAULT,
p_xxxx TYPE xxxx OBLIGATORY DEFAULT.
SELECT-OPTIONS 可以输入单值,多值,范围
还可以包含,排除,同时搭配OPEN-SQL从数据库里查询值
SELECT-OPTIONS: s_xxx FOR xxx,
s_xxx FOR xxx DEFAULT xxx.
SELECT-OPTIONS: s_xxx1 FOR xxx NO INTERVALS NO-EXTENSION, " 和 PARAMETERS 一样
s_xxx2 FOR xxx NO INTERVALS, "可输入多值
s_xxx3 FOR xxx. :可输入多值,范围
为了使选择屏幕的输入更具有针对性,有时我们会让它动起来
就是动态显示选择屏幕的内容
SELECT-OPTIONS: s_xxx1 FOR xxx NO INTERVALS NO-EXTENSION MEMORY ID s1 MODIF ID ty1,
s_xxx2 FOR xxx NO INTERVALS MEMORY ID s2 MODIF ID ty2,
s_xxx3 FOR xxx MEMORY ID s3 MODIF ID ty3 . "可输入多值,范围
PARAMETERS: p_xxx1 RADIOBUTTON GROUP g1 USER-COMMAND uc DEFAULT 'X',
p_xxx2 RADIOBUTTON GROUP g1.
p_xxx3 RADIOBUTTON GROUP g1.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN. "LOOP 很关键,就是全部循环来控制哪些显示1 哪些隐藏 0
IF screen-group1 EQ 'TY1' AND p_xxx1 NE 'X'.
* screen-invisible = 1.
screen-active = 0. "0 隐藏, 1显示
ENDIF.
IF screen-group1 EQ 'TY2' AND p_xxx2 NE 'X'.
screen-active = 0.
ENDIF.
IF screen-group1 EQ 'TY3' AND p_xxx3 NE 'X'.
screen-active = 0.
ENDIF.
MODIFY SCRENN.
ENDLOOP.
以上的效果是选择屏幕会根据单选框的选择进行变化
这里有几点需要注意,
我们在SELECT-OPTIONS 里还加入了 MEMORY ID xx
这是用来记录我们屏幕上输入的值
当我们再次执行程序时,它会自动带出我们上一次输入的值
这会减少用户的输入,是非常值得使用的
有的时候单选框所占用的位置太多了,我们可以使用下拉框来限制用户的输入
TYPE-POOLS:vrm.
DATA: gv_name TYPE vrm_id,
gt_list TYPE vrm_values,
gs_list LIKE LINE OF gt_list.
PARAMETERS : p_type(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
gv_name = 'P_TYPE'.
gs_list-key = '1'.
gs_list-text = '失败'.
APPEND gs_list TO gt_list.
gs_list-key = '2'.
gs_list-text = '成功'.
APPEND gs_list TO gt_list.
gs_list-key = '3'.
gs_list-text = '全部'.
APPEND gs_list TO gt_list.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = gv_name values = gt_list.