(1)SELECTION-SCREEN COMMONT fmt name.
用于定义或者修改本地元素的注释,包括PARAMETER、CHECKBOX BUTTON等。通过SELECTION-SCREEN COMMENT语法可以按Text Symbols设置的值对其属性重新定义。
[For Example]
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (12) TEXT-W03 FOR FIELD parm.
SELECTION-SCREEN POSITION 14.
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-W04 FOR FIELD type.
SELECTION-SCREEN END OF LINE.
Text-Symbols设置如下:
程序运行界面如下:
(2)SELECTION-SCREEN FUNCTION KEY n.
该对象用于在工具栏上新增一个功能按钮。该按钮的定义保存在系统结构体SSCRFIELDS中,n为一个整数序数最大至5。不要试图让它小于1或者大于5,它不接受这个范围。也就是说工具栏按钮最多可以放5个(whereby a value between 1 and 5 must be entered for n)。当n等于1时,其按钮描述保存在字段SSCRFIELDS-FUNCTXT_01中,其按钮对象命名为
"FC01",保存在字段SSCRFIELDS-UCOMM中,以下为示例代码:
[For Example]
PARAMETERS para LIKE MARA-MATNR.
TABLES: SSCRFIELDS.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
SELECTION-SCREEN FUNCTION KEY 5.
INITIALIZATION. "初始公屏幕时,就给它们一些值吧,让它们看起来更像是个按钮,按钮也需要有尊严的活着。
MOVE ‘Add BUTTON‘ TO SSCRFIELDS-FUNCTXT_01.
MOVE ‘Minus BUTTON‘ TO SSCRFIELDS-FUNCTXT_02.
MOVE ‘MODIFY BUTTON‘ TO SSCRFIELDS-FUNCTXT_05.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = ‘FC05‘. "触发 FC05工具栏按钮,将要执行什么操作
CALL SELECTION-SCREEN 1234."调用程序中的子屏幕
ENDIF.
运行界面如下:
以下代码来自官方网站上面的例子:
*官方菜单SELECTION-SCREEN FUNCTION KEY n (demo:http://help.sap.com/abapdocu_70/en/ABAPSELECTION-SCREEN_FUNCTIONKEY.htm)
TYPE-POOLS ICON. "Program Icon Library
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.
运行界面如下:
(3)SELECTION-SCREEN BEGIN OF TABBED BLOCK <block> FOR n LINES.
定义选项卡或者其他类似于选择页切换的功能组件。具体语法如下:
[Syntax]
SELECTION-SCREEN: BEGIN OF TABBED BLOCK <sub_area> FOR n LINES,
[......]
END OF BLOCK <sub_area>.
其中 n代表高度,此高度为选择控件的高度。
例1:
[Code]
TABLES:MARA.
*定义子屏幕100 SUBSCREEN
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK blockA WITH FRAME TITLE TEXT-W01.
SELECT-OPTIONS:mantra FOR MARA-MATNR NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS: check01 AS CHECKBOX DEFAULT ‘X‘.
SELECTION-SCREEN END OF BLOCK blockA.
SELECTION-SCREEN END OF SCREEN 100.
*定义子屏幕200 SUBSCREEN
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
PARAMETERS: mantrb LIKE MARA-MATNR.
SELECTION-SCREEN END OF SCREEN 200.
*选择页TAB功能,定义两个TAB
SELECTION-SCREEN:
BEGIN OF TABBED BLOCK MyTab FOR 5 LINES,
TAB (20) BUTTON1 USER-COMMAND PUSH1, *(20)代表要显示在TAB内容的长度,最大长度为79,不相信?你可以试下.哈哈
TAB (20) BUTTON2 USER-COMMAND PUSH2,
END OF BLOCK MyTab.
INITIALIZATION.
BUTTON1 = ‘FirstTab‘.
BUTTON2 = ‘SecondTab‘.
MyTab-PROG = SY-REPID. *指定调用的程序名
MyTab-DYNNR = 100. *指定当前要显示的屏幕
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN ‘PUSH1‘.
MyTab-DYNNR = 100.
MyTab-ACTIVETAB = ‘BUTTON1‘.
WHEN ‘PUSH2‘.
MyTab-DYNNR = 200.
MyTab-ACTIVETAB = ‘BUTTON2‘.
ENDCASE.
运行界面如下:
例2:
[CODE] The Official Demo
TABLES SSCRFIELDS.
* SUBSCREEN 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.
* SUBSCREEN 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.
* SUBSCREEN 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 = ‘@[email protected]‘. "按钮描述字段,图标形貌
sscrfields-functxt_02 = ‘@[email protected]‘. "按钮描述字段,图标形貌
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.
运行界面如下: