sap的选择屏幕的标准工具栏上系统预先定义了5个按钮,他们对应的功能码是FC01-FC05,默认是不激活的。用户可以使用SELECTION-SCREEN FUNCTION KEY i.来激活这5个按钮(这里的i必须是1-5),这五个按钮的文本放在SSCRFields的对应的Functxt_0i中。当用户按下按钮时,系统将触发AT SELECTION-SCREEN 事件,并将功能码放到sscrfields的ucomm字段中。
代码样例:
REPORT demo_sel_screen_function_key.
TABLES sscrfields. "定义工作区
PARAMETERS: p_carrid TYPE s_carr_id,
p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1, "激活按钮
FUNCTION KEY 2.
INITIALIZATION.
sscrfields-functxt_01 = 'LH'. "定义按钮文本
sscrfields-functxt_02 = 'UA'.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm. "处理按钮命令
WHEN'FC01'.
p_carrid = 'LH'.
p_cityfr = 'Frankfurt'.
WHEN 'FC02'.
p_carrid = 'UA'.
p_cityfr = 'Chicago'.
ENDCASE.
START-OF-SELECTION.
WRITE / 'START-OF-SELECTION'.
注意:在AT SELECTION-SCREEN事件执行后,系统将再次显示屏幕,只有当用选择Execute(F8),系统才会进行其他事件的执行。
代码样例:
REPORT demo_sel_screen_function_key.
TABLES sscrfields. "定义工作区
PARAMETERS: p_carrid TYPE s_carr_id,
p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1, "激活按钮
FUNCTION KEY 2.
INITIALIZATION.
sscrfields-functxt_01 = 'LH'. "定义按钮文本
sscrfields-functxt_02 = 'UA'.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm. "处理按钮命令
WHEN'FC01'.
p_carrid = 'LH'.
p_cityfr = 'Frankfurt'.
WHEN 'FC02'.
p_carrid = 'UA'.
p_cityfr = 'Chicago'.
ENDCASE.
START-OF-SELECTION.
WRITE / 'START-OF-SELECTION'.
注意:在AT SELECTION-SCREEN事件执行后,系统将再次显示屏幕,只有当用选择Execute(F8),系统才会进行其他事件的执行。