1. SELECTIION-SCREEN的語法:
SELECTION-SCREEN BEGIN OF SCREEN SCR.
...
SELECTION-SCREEN END OF SCREEN SCR.
2. 通过SELECTION-SCREEN定义窗体。(当从一个主屏幕中来调用基程序中的另一个窗体时,必须使用CALL SELECTION-SCREEN的方法)
SELECTION-SCREEN BEGIN OF SCREEN 123 AS WINDOW TITLE TEXT-001.
PARAMETERS:S_MATNR LIKE MARA-MATNR.
PARAMETERS:TYPE AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 123.
CALL SCREEN 123
STARTING AT 10 10
ENDING AT 80 10. "调用SELECTION-SCREEN
3. 通过SELECTION-SCREEN调用Include screen.
PARAMETERS:TYPE AS CHECKBOX. "第一个窗体元素
CALL SELECTION-SCREEN 123."SELECTION-SCREEN调用另一个窗体
SELECTION-SCREEN BEGIN OF SCREEN 123 AS WINDOW TITLE TEXT-001.
PARAMETERS:MATNR LIKE MARA-MATNR.
SELECTION-SCREEN END OF SCREEN 123.
按【F8】执行,会出现如下画面
4.SELECTION-SCREEN BEGIN OF SCREEN scr AS SUBSCREEN.
该语法用于定义一个Subscreen, Subscreen主要应用于Screen Painter所创建屏幕。
5.
SELECTION-SCREEN BEGIN OF BLOCK BLOCK.
...
SELECTION-SCREEN END OF BLOCK.
该语法在屏幕中定义一个BLOCK,其扩展语法包括:
...WITH FRAME:创建一个框架。
...TITLE title:创建一个带标题的框架。
...NO INTERVALS:所创建的框架中限制SELECT 只有一个输入项。
DATA MAT LIKE MARA-MATNR.
*不包含扩展语法
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1.
SELECT-OPTIONS:MATNR1 FOR MAT.
SELECTION-SCREEN END OF BLOCK BLOCK1.
*包含框架
SELECTION-SCREEN BEGIN OF BLOCK BLOCK2 WITH FRAME.
SELECT-OPTIONS:MATNR2 FOR MAT.
SELECTION-SCREEN END OF BLOCK BLOCK2.
*包含框架及标头
SELECTION-SCREEN BEGIN OF BLOCK BLOCK3 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:MATNR3 FOR MAT.
SELECTION-SCREEN END OF BLOCK BLOCK3.
*包含框架及标头且只有一个输入框
SELECTION-SCREEN BEGIN OF BLOCK BLOCK4 WITH FRAME TITLE TEXT-002 NO INTERVALS.
SELECT-OPTIONS:MATNR4 FOR MAT.
SELECTION-SCREEN END OF BLOCK BLOCK4.
6. SELECTION-SCREEN INCLUDE
参照某一个已经定义的屏幕元素来创建.
CALL SCREEN 1234.
SELECTION-SCREEN BEGIN OF SCREEN 1111.
SELECTION-SCREEN BEGIN OF BLOCK BLK1.
SELECT-OPTIONS SEL0 FOR SY-REPID.
SELECTION-SCREEN ULINE. "换行线
PARAMETERS PAR0.
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN END OF SCREEN 1111.
SELECTION-SCREEN BEGIN OF SCREEN 1234.
SELECTION-SCREEN INCLUDE BLOCKS BLK1."參照SCREEN 111中的BLOCK
SELECTION-SCREEN END OF SCREEN 1234.
7. SELECTION-SCREEN ULINE. 輸出橫線,必須用在BLOCK中才生效.
8. SELECTION-SCREEN SKIP n. 在BLOCK中產生換行.
9. SELECTION-SCREEN POSITION pos. 在BLOCK中产生空格.
10. 将所产生的屏幕元素控制在一行.
SELECTION-SCREEN BEGIN OF LINE.
...
SELECTION-SCREEN END OF LINE.
11. AT SELECTION-SCREEN . 用于屏幕输入检验,其扩展语法如下:
...ON <Field>: 该语法用于控制屏幕元素输入时的遇错处理,检查某具体输入字段
(SELECT-OPTIONS 或PARAMETERS)是否完整或正确,若输入有错或不满足条件,其他字段会变灰色直到该字段输入正确.
...ON RADIOBUTTON GROUP <radio>:按制RadioButto组值的输入;
...ON BLOCK <block>:控制框架中的屏幕元素值的输入;
...OUTPUT:用于屏幕输出时的各屏幕元素值的管控;
...ON EXIT-COMMAND:用于响应"Back"、"Canne"、及"Exit"等事件。
SELECT-OPTIONS SEL0 FOR SY-TVAR0.
SELECTION-SCREEN BEGIN OF BLOCK BL0.
SELECT-OPTIONS SEL1 FOR SY-TVAR1.
SELECTION-SCREEN BEGIN OF BLOCK BL1.
PARAMETERS P1 RADIOBUTTON GROUP RAD1.
PARAMETERS P2 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN BEGIN OF BLOCK BL2.
PARAMETERS P3.
SELECTION-SCREEN END OF BLOCK BL2.
SELECT-OPTIONS SEL2 FOR SY-TVAR2.
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN END OF BLOCK BL0.
AT SELECTION-SCREEN ON SEL1.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD1.
AT SELECTION-SCREEN ON P3.
AT SELECTION-SCREEN ON BLOCK BL1.
AT SELECTION-SCREEN ON BLOCK BL2.
12.SELECTION-SCREEN PUSHBUTTION fmt name USER-COMMAND ucom
用于在SELECTION SCREEN中产生一个按钮(pushbutton),fmt name为定义该按钮的属性值。可以对其赋值描述及添加图标,USER-COMMAND ucom定义该按钮在Screen中的组件名,
对按钮属性赋值可以包括两种方式。
REPORT Y001.
INCLUDE <ICON>.
SELECTION-SCREEN PUSHBUTTON /1(20) PUBU1 USER-COMMAND ABCD.
SELECTION-SCREEN SKIP."加入空行以便区分
SELECTION-SCREEN PUSHBUTTON /1(20) PUBU2 USER-COMMAND ABCD.
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.
(若要更换按钮图标,请参考 Tcode: ICON)
13. SELECTION-SCREEN COMMENT fmt name.
用于定义或修改本地元素 的注释,包括Parameter、Checkbox Button等。例如Checkbox Button的描述,其在Selection texts中最长字段只有30位,通过SELECTION-SCREEN COMMENT语法可以按Text Symbols设置值对其属性重新定义。
REPORT Y001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (40) TEXT-A01 FOR FIELD PARM.
SELECTION-SCREEN POSITION 45.
PARAMETERS PARM LIKE MARA-MATNR.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:TYPE AS CHECKBOX.
SELECTION-SCREEN COMMENT (40) TEXT-A02 FOR FIELD TYPE.
SELECTION-SCREEN END OF LINE.
14. SELECTION-SCREEN FUNCTION KEY n.
用于在工具栏上新增一个功能按钮。该按钮的定义保存在系统结构体SSCRFIELDS中,n为一个整数的序数,例如当n等于1时,其按钮描述保存在字段SSCRFIELDS-FUNCTXT_01中,其按钮对象命名为“FC01",保存在字段SSCRFIELDS-UCOMM中。具体使用方法如下:
REPORT Y001.
PARAMETERS PARM LIKE MARA-MATNR.
TABLES SSCRFIELDS.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
INITIALIZATION.
MOVE 'BUTTON1' TO SSCRFIELDS-FUNCTXT_01.
MOVE 'BUTTON2' TO SSCRFIELDS-FUNCTXT_02.
REPORT Y001.
PARAMETERS PARM LIKE MARA-MATNR.
TABLES SSCRFIELDS.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
SELECTION-SCREEN FUNCTION KEY 3.
INITIALIZATION.
MOVE 'BUTTON1' TO SSCRFIELDS-FUNCTXT_01.
MOVE 'BUTTON2' TO SSCRFIELDS-FUNCTXT_02.
MOVE 'BUTTON3' TO SSCRFIELDS-FUNCTXT_03.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'FC01'.
CALL SELECTION-SCREEN 123.
ENDIF.
对工具栏按钮的操作同样通过屏幕时间来实现,如上所述,对象命我为”FC01",保存存在字段SSCRFIELDS-UCOMM中。
TYPE-POOLS ICON.
TABLES SSCRFIELDS.
DATA FUNCTXT TYPE SMP_DYNTXT."SMP_DYNTXT(菜单制作器:动态文本的程序接口)
PARAMETERS: P_CARRID TYPE S_CARR_ID,
P_CITYFR TYPE S_FROM_CIT.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
INITIALIZATION. "屏幕初始化
FUNCTXT-ICON_ID = ICON_WS_PLANE."文本字段中的图标(替换显示,别名)
FUNCTXT-QUICKINFO = 'Preselected Carrier'."菜单制作器:信息文本 (4.0),滑鼠移去过去显示的信息TIP
FUNCTXT-ICON_TEXT = 'LH'."菜单制作器:图标文本 (4.0),菜单名称
SSCRFIELDS-FUNCTXT_01 = FUNCTXT.
FUNCTXT-ICON_TEXT = 'UA'.
SSCRFIELDS-FUNCTXT_02 = FUNCTXT.
AT SELECTION-SCREEN.
CASE SSCRFIELDS-UCOMM.
WHEN 'FC01'.
P_CARRID = 'LH'.
P_CITYFR = 'Frankfurt'.
WHEN 'FC02'.
P_CARRID = 'UA'.
P_CITYFR = 'Chicago'.
ENDCASE.
15.SELECTION-SCREEN BEGIN OF TABBED BLOCK <block> FOR n LINES.
用于在屏幕上定义一个分页控件(tab),每个页签都是由一个子屏幕控制,n代表分页控件的高度,屏幕载入时必须先通过INTIALIZATION事件对其司性初始化,如定义两个分页的TAB控件,具体如下:
REPORT Y001.
TABLES:MARA.
*定义子屏幕100
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK A1 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 A1.
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,共人两个选项卡BUTTON1BUTTON2
*两个选项卡的功能代码分别为PUSH1PUSH2
SELECTION-SCREEN:BEGIN OF TABBED BLOCK MYTAB FOR 5 LINES,*指框框高度為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.
TABLES SSCRFIELDS.
* 定义子屏幕为100
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
PARAMETERS: P1(10) TYPE C,
P2(10) TYPE C,
P3(10) TYPE C.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.
* 定义子屏幕为200
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.
PARAMETERS: Q1(10) TYPE C,
Q2(10) TYPE C,
Q3(10) TYPE C.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.
*定义子屏幕为300
SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.
PARAMETERS: R1(10) TYPE C,
R2(10) TYPE C,
R3(10) TYPE C.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.
* STANDARD SELECTION SCREEN
SELECTION-SCREEN: FUNCTION KEY 1, "工具栏按钮
FUNCTION KEY 2.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 10 LINES,
END OF BLOCK SUB.
INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = '@0D@'. "按钮描述字段,图标形貌
SSCRFIELDS-FUNCTXT_02 = '@0E@'. "按钮描述字段,图标形貌
SUB-PROG = SY-REPID. "必选项
SUB-DYNNR = 100.
AT SELECTION-SCREEN.
CASE SY-DYNNR. "当前显示屏幕的名称
WHEN 100.
IF SSCRFIELDS-UCOMM = 'FC01'. "触发事件的TOOL BAR CONTROL
SUB-DYNNR = 300. "指定显示哪个屏幕
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 200.
ENDIF.
WHEN 200.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 100.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 300.
ENDIF.
WHEN 300.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 200.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 100.
ENDIF.
ENDCASE.
START-OF-SELECTION.
WRITE: / 'P1:', P1,'Q1:', Q1, 'R1:', R1,
/ 'P2:', P2,'Q2:', Q2, 'R2:', R2,
/ 'P3:', P3,'Q3:', Q3, 'R3:', R3.
REPORT Y001.
TABLES SSCRFIELDS.
SELECTION-SCREEN:
ULINE /1(83),
COMMENT /30(30) TEXT-001,
ULINE /1(83),
SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(15) TXT1.
PARAMETER OUT(3) TYPE C.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN:
SKIP 1,
BEGIN OF BLOCK BLK WITH FRAME TITLE T1,
BEGIN OF LINE,
PUSHBUTTON 2(10) BTN1 USER-COMMAND COMM1,
PUSHBUTTON 12(10) BTN2 USER-COMMAND COMM2,
PUSHBUTTON 22(10) BTN3 USER-COMMAND COMM3,
END OF LINE,
END OF BLOCK BLK.
*&---------------------------------------------------------------------*
INITIALIZATION.
TXT1 = '总分: '.
T1 = '给选择屏幕添加按钮'.
BTN1 = '汤姆'.
BTN2 = '露西'.
BTN3 = '韩梅梅'.