SAP-ABAP SELECT-SCREEN 的几个用法
如下一段程序:
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETER P_FLEX RADIOBUTTON GROUP ways TYPE c.
SELECTION-SCREEN COMMENT 3(20) text-s30 for field P_FLEX.
SELECTION-SCREEN COMMENT 25(10) text-s31 for field P_PAYM_B.
SELECTION-SCREEN POSITION 38.
PARAMETER P_PAYM_B LIKE PA0015-PABRP MODIF ID wty.
parameters P_PAYY_B LIKE PA0015-pabrj MODIF ID wty.
SELECTION-SCREEN POSITION 57.
SELECTION-SCREEN COMMENT 57(5) text-s32 for field P_PAYM_E.
parameters P_PAYM_E LIKE PA0015-pabrp MODIF ID wty.
parameters P_PAYY_E LIKE PA0015-pabrj MODIF ID wty.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 25.
SELECTION-SCREEN COMMENT 25(9) text-s18 for field S_LGART.
SELECT-OPTIONS S_LGART FOR p0014-LGART MODIF ID wty.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 1.
本程序中涉及到几个SELECTION-SCREEN的用法:
1 SELECTION-SCREEN BEGIN OF LINE. ....END OF LINE.
这条语句的作用是让Begin of line 与End of line之间的部分位于同一行。
2 SELECTION-SCREEN POSITION XX.
这条语句的作用是将该语句后面的第一个Screen element定位在这一行的XX位置,最大值为79。值得注意的是,如果同一行中多个Position语句因为空间不够或Element所占空间重叠,将导致Screen创建时的错误,无法激活。此时并无具体的提示。只能仔细观察代码。
3 SELECTION-SCREEN COMMENT XX(Y) TEXT-XXX FOR FIELD XXX.
这条语句的作用是在当前行的指定列位置处输出一段文本,For field则表示文本与某个element 关联,当此语句使用时,可以不必设定屏幕的Text element,系统会自动关联。XX表示位置,Y表示长度,注意,如果长度不足,超常的文字将被截掉。此处似乎还有一个小BUG,当Y小于5时,输出的文字字体会变大一号。不知道为什么。
SELECTION-SCREEN COMMENT /10(30) comm1.
INITIALIZATION.
4 SELECTION-SCREEN SKIP 1.
跳过一行。类似于用WRITE写Report时的SKIP 1.也可以跳过多行。
以下是 屏幕上画横线
5.内存记忆 留有上次输入过的记录
parameters test(16) type c memory id rid.
6.检查输入值 如果不在表中 不用做代码检查了
PARAMETERS p_carr TYPE spfli-carrid OBLIGATORY VALUE CHECK.
7.复选框
PARAMETERS: a AS CHECKBOX,
8.单选框
PARAMETERS: r1 RADIOBUTTON GROUP rad1,
9.屏幕动作变化 引起屏幕变化: modif id 起作用
举例:
report a.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME title TEXT-003.
PARAMETERS:
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME
SELECTION-SCREEN: BEGIN OF LINE,
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN: BEGIN OF LINE,
SELECTION-SCREEN END OF BLOCK BL2.
"在AT SELECTION-SCREEN中循环SCREEN系统变量,把需要修改的画面元素的属性进行相应的修改
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
10.ranges 使用方法
ranges s_carrid1 for spfli-carrid.
s_carrid1-sign
s_carrid1-option = 'EQ'.
s_carrid1-low
append s_carrid1.
11. options限制 输入
SELECT-OPTIONS airline FOR wa_spfli-carrid NO INTERVALS
12. 一行中的若干元素
DATA wa_spfli TYPE spfli.
SELECT-OPTIONS airline FOR wa_spfli-carrid.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION pos_high.
PARAMETERS field(5) TYPE c.
SELECTION-SCREEN END OF LINE.
13 屏幕元素事件 按钮
TABLES sscrfields.
DATA flag(1) TYPE c.
SELECTION-SCREEN:
AT SELECTION-SCREEN.
START-OF-SELECTION.
14
REPORT demo_sel_screen_function_key.
TABLES sscrfields.
PARAMETERS: p_carrid TYPE s_carr_id,
SELECTION-SCREEN: FUNCTION KEY 1,
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
15.关于修改 标准status (有待研究)
REPORT demo_sel_screen_status .
DATA itab TYPE TABLE OF sy-ucomm.
PARAMETERS test(10) TYPE c.
AT SELECTION-SCREEN OUTPUT.
16.选择屏幕 事件何时触发(有待研究)
REPORT demo_selection_screen_events MESSAGE-ID sabapdocu.
DATA field1(10) TYPE c.
SELECT-OPTIONS sel_opt1 FOR field1.
SELECTION-SCREEN BEGIN OF BLOCK block1.
PARAMETERS:
SELECTION-SCREEN END OF BLOCK block1.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',
AT SELECTION-SCREEN.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN ON sel_opt1.
AT SELECTION-SCREEN ON test1.
AT SELECTION-SCREEN ON test2.
AT SELECTION-SCREEN ON END OF sel_opt1.
AT SELECTION-SCREEN ON HELP-REQUEST FOR sel_opt1-low.
AT SELECTION-SCREEN ON HELP-REQUEST FOR sel_opt1-high.
AT SELECTION-SCREEN ON HELP-REQUEST FOR test1.
AT SELECTION-SCREEN ON HELP-REQUEST FOR test2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_opt1-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_opt1-high.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR test1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR test2.
AT SELECTION-SCREEN ON BLOCK block1.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.