1,AT SELECTION-SCREEN
AT SELECTION-SCREEN . 用于屏幕输入检验,其扩展语法如下:
...ON <Field>: 该语法用于控制屏幕元素输入时的遇错处理,检查某具体输入字段
(SELECT-OPTIONS 或PARAMETERS)是否完整或正确,若输入有错或不满足条件,其他字段会变灰色直到该字段输入正确.
...ON RADIOBUTTON GROUP <radio>:按制RadioButto组值的输入;
...ON BLOCK <block>:控制框架中的屏幕元素值的输入;
...OUTPUT:用于屏幕输出时的各屏幕元素值的管控;
...ON EXIT-COMMAND:用于响应"Back"、"Cancel"、及"Exit"等事件。
例子代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
TABLES:marc. SELECT-OPTIONS s_matnr FOR marc-matnr. SELECTION-SCREEN BEGIN OF BLOCK bl0. SELECTION-SCREEN BEGIN OF BLOCK bl1. PARAMETERS:p_ocmpf TYPE marc-ocmpf. SELECTION-SCREEN END OF BLOCK bl1. PARAMETERS:p_werks TYPE marc-werks. PARAMETERS:p1 RADIOBUTTON GROUP rad1, p2 RADIOBUTTON GROUP rad1. SELECTION-SCREEN END OF BLOCK bl0. AT SELECTION-SCREEN ON s_matnr. AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad1. AT SELECTION-SCREEN ON p_werks. AT SELECTION-SCREEN ON BLOCK bl1. |
屏幕:
2, 选择屏幕上定义按钮
语法如下:
SELECTION-SCREEN PUSHBUTTION fmt name USER-COMMAND ucom
用于在SELECTION SCREEN中产生一个按钮(pushbutton),fmt name为定义该按钮的属性值。可以对其赋值描述及添加图标,USER-COMMAND ucom定义该按钮的function code,对按钮属性赋值可以包括两种方式。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
TABLES sscrfields. INCLUDE <icon>. SELECTION-SCREEN PUSHBUTTON /1(20) pubu1 USER-COMMAND fcode1. SELECTION-SCREEN SKIP."加入空行以便区分 SELECTION-SCREEN PUSHBUTTON /1(20) pubu2 USER-COMMAND fcode2. AT SELECTION-SCREEN OUTPUT. MOVE 'My Button' TO pubu1. "定义第一个按钮并赋值描述 WRITE icon_graphics AS ICON TO pubu2."定义第二个按钮并添加图标 CONCATENATE pubu2 'MY BUTTON'INTO pubu2 SEPARATED BY space . AT SELECTION-SCREEN. * 响应按钮的function code CASE sscrfields-ucomm . WHEN 'FCODE1'. MESSAGE 'focde1' TYPE 'S'. WHEN 'FCODE2'. MESSAGE 'focde2' TYPE 'S'. ENDCASE. |
屏幕:
若要更换按钮图标,请参考 Tcode: ICON
3, 工具栏上新增一个功能按钮
可以在选择画面工具栏上添加自定义按钮,语法如下:
SELECTION-SCREEN FUNCTION KEY n
该按钮的定义保存在系统结构体SSCRFIELDS中,n为一个整数的序数,最大5,例如当n等于1时,其按钮描述保存在字段SSCRFIELDS-FUNCTXT_01中,其按钮对象命名为“FC01",保存在字段SSCRFIELDS-UCOMM中。
对工具栏按钮的操作同样通过屏幕时间来实现,如上所述,对象命我为”FC01",保存存在字段SSCRFIELDS-UCOMM中。
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
TABLES sscrfields. DATA:gv_functxt TYPE smp_dyntxt. PARAMETERS p_parm LIKE mara-matnr. SELECTION-SCREEN FUNCTION KEY 1. SELECTION-SCREEN FUNCTION KEY 2. INITIALIZATION. gv_functxt-icon_id = icon_ws_plane."文本字段中的图标(替换显示,别名) gv_functxt-quickinfo = 'Preselected Carrier'."菜单制作器:信息文本 (4.0),滑鼠移去过去显示的信息TIP gv_functxt-icon_text = 'LH'."菜单制作器:图标文本 (4.0),菜单名称 sscrfields-functxt_01 = gv_functxt. gv_functxt-icon_text = 'UA'. sscrfields-functxt_02 = gv_functxt. AT SELECTION-SCREEN. * 响应按钮的function code CASE sscrfields-ucomm . WHEN 'FC01'. MESSAGE 'button1' TYPE 'S'. WHEN 'FC02'. MESSAGE 'button2' TYPE 'S'. ENDCASE. |
屏幕:
4,定义tab分页
语法如下:
SELECTION-SCREEN BEGIN OF TABBED BLOCK <block> FOR n LINES.
用于在屏幕上定义一个分页控件(tab),每个页签都是由一个子屏幕控制,n代表分页控件的高度,屏幕载入时必须先通过INTIALIZATION事件对其属性初始化,如定义两个分页的TAB控件.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
TABLES:MARA. *定义子屏幕100 SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS:S_MATNR FOR MARA-MATNR NO INTERVALS. SELECTION-SCREEN SKIP 1. PARAMETERS:TYPE AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK blk1. SELECTION-SCREEN END OF SCREEN 100. *定义子屏幕200 SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN. PARAMETERS:S_MATNR2 LIKE MARA-MATNR. SELECTION-SCREEN END OF SCREEN 200. *定义一个TAB空间,取名为MYTAB,控件高为5,共两个选项卡BUTTON1\BUTTON2 *两个选项卡的功能代码分别为PUSH1\PUSH2 SELECTION-SCREEN:BEGIN OF TABBED BLOCK MYTAB FOR 5 LINES, "Tab框高度5LINES. TAB (20) BUTTON1 USER-COMMAND PUSH1, TAB (20) BUTTON2 USER-COMMAND PUSH2, END OF BLOCK MYTAB. INITIALIZATION. BUTTON1 = TEXT-010. BUTTON2 = TEXT-020. MYTAB-PROG = SY-REPID. MYTAB-DYNNR = 100. "默认屏幕 *TAB控件选项卡单击事件,选择不同选项卡显示不同子屏幕 AT SELECTION-SCREEN. CASE SY-UCOMM. WHEN 'PUSH1'. MYTAB-DYNNR = 100. MYTAB-ACTIVETAB = 'BUTTON1'. WHEN 'PUSH2'. MYTAB-DYNNR = 200. MYTAB-ACTIVETAB = 'BUTTON2'. ENDCASE. |
屏幕:
上例中的tab页,如果不指定BUTTON1,BUTTON2,则生成的tab分页是下面的样子
以上.
发表评论