SAP-ABAP SELECT-SCREEN
Posted js47
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SAP-ABAP SELECT-SCREEN相关的知识,希望对你有一定的参考价值。
* SELECTION-SCREEN BEGIN OF LINE. ....END OF LINE.
让Begin of line 与End of line之间的部分位于同一行。
* SELECTION-SCREEN POSITION XX.
将该语句后面的第一个Screen element定位在这一行的XX位置,最大值为79。值得注意的是,如果同一行中多个Position语句因为空间不够或Element所占空间重叠,将导致Screen创建时的错误,无法激活。此时并无具体的提示。只能仔细观察代码。
* SELECTION-SCREEN COMMENT XX(Y) TEXT-XXX FOR FIELD XXX.
在当前行的指定列位置处输出一段文本,For field则表示文本与某个element 关联,当此语句使用时,可以不必设定屏幕的Text element,系统会自动关联。XX表示位置,Y表示长度,如果长度不足,超常的文字将被截掉。
SELECTION-SCREEN COMMENT /10(30) comm1.
INITIALIZATION.
comm1 =‘Auswahlknopfgruppe 1‘.
* SELECTION-SCREEN SKIP 1.
跳过一行。类似于用WRITE写Report时的SKIP 1.也可以跳过多行。
以下是 屏幕上画横线
SELECTION-SCREEN ULINE /1(50).
* 内存记忆 留有上次输入过的记录
parameters test(16) type c memory id rid.
MEMORY ID
在SAP内定义的一段内存区域,方便你从里边读出数据或者往里边写入数据。MEMORY ID pid 使用内存默认值。从SAP内存(该内存是用户相关的公有内存区域,可以在一个用户使用的不同会话之间传递)中给参数字段分配默认值,SAP/GPA参数是SAP将屏幕元素填充初始数据的一种通用技术,其中rid是公用的SAP内存ID,最多20字节,通过SET/GET语句进行设定和读取
* 检查输入值 如果不在表中 不用做代码检查了
PARAMETERS p_carr TYPE spfli-carrid OBLIGATORY VALUE CHECK.
* 复选框
PARAMETERS: a AS CHECKBOX,
b AS CHECKBOX DEFAULT ‘X‘.
* 单选框
PARAMETERS: r1 RADIOBUTTON GROUP rad1,
r2 RADIOBUTTON GROUP rad1 DEFAULT ‘X‘,
r3 RADIOBUTTON GROUP rad1,
s1 RADIOBUTTON GROUP rad2,
s2 RADIOBUTTON GROUP rad2,
s3 RADIOBUTTON GROUP rad2 DEFAULT ‘X‘.
* 下拉框
PARAMETERS: P_LANG(20) AS LISTBOX VISIBLE LENGTH 22.
DATA: INIT .
AT SELECTION-SCREEN OUTPUT.
PERFORM SETLIST.
FORM SETLIST.
TYPE-POOLS VRM.
DATA VALUES TYPE VRM_VALUES WITH HEADER LINE.
VALUES-KEY = ‘CHINESE‘. APPEND VALUES.
VALUES-KEY = ‘AMERICAN‘. APPEND VALUES.
VALUES-KEY = ‘ENGLISH‘. APPEND VALUES.
VALUES-KEY = ‘ENGLISH3‘. APPEND VALUES.
VALUES-KEY = ‘ENGLISH4‘. APPEND VALUES.
IF INIT IS INITIAL.
CALL FUNCTION ‘VRM_SET_VALUES‘
EXPORTING
ID = ‘P_LANG‘
VALUES = VALUES[]
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2.
ENDIF.
INIT = ‘X‘.
ENDFORM.
* 屏幕动作变化 引起屏幕变化: modif id 起作用
举例:
SELECTION-SCREEN BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-T01.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS P1 RADIOBUTTON GROUP RG1 USER-COMMAND UC DEFAULT ‘X‘.
SELECTION-SCREEN COMMENT 4(14) TEXT-001 ."导入
SELECTION-SCREEN POSITION 20.
PARAMETERS P2 RADIOBUTTON GROUP RG1 .
SELECTION-SCREEN COMMENT 23(14) TEXT-002."维护
SELECTION-SCREEN POSITION 40.
PARAMETERS P3 RADIOBUTTON GROUP RG1.
SELECTION-SCREEN COMMENT 43(14) TEXT-003."查询
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: P_GJAHR FOR ACDOCA-GJAHR NO INTERVALS NO-EXTENSION DEFAULT SY-DATUM(4) MODIF ID MD1,
P_POPER FOR ACDOCA-POPER NO INTERVALS NO-EXTENSION DEFAULT SY-DATUM+4(2) MODIF ID MD1.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN COMMENT 1(14) TEXT-004 MODIF ID MD2.
PARAMETERS: P_SEL TYPE RLGRAP-FILENAME MODIF ID MD2 .
SELECTION-SCREEN END OF BLOCK BLK01.
AT SELECTION-SCREEN OUTPUT.
PERFORM FRM_SET_SCREEN."选择屏幕字段集设置
"在AT SELECTION-SCREEN中循环SCREEN系统变量,把需要修改的画面元素的属性进行相应的修改
FORM FRM_SET_SCREEN.
LOOP AT SCREEN.
CASE SCREEN-GROUP1.
WHEN ‘MD1‘.
CASE L_STA.
WHEN P1.
SCREEN-ACTIVE = 0.
WHEN P2.
SCREEN-ACTIVE = 0.
WHEN P3.
SCREEN-ACTIVE = 1.
ENDCASE.
WHEN ‘MD2‘.
CASE L_STA.
WHEN P1.
SCREEN-ACTIVE = 1. "显示
WHEN P2.
SCREEN-ACTIVE = 0."隐藏
WHEN P3.
SCREEN-ACTIVE = 0.
ENDCASE.
WHEN OTHERS.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
ENDFORM.
* ranges 使用方法
ranges s_carrid1 for spfli-carrid.
s_carrid1-sign = ‘I‘.
s_carrid1-option = ‘EQ‘.
s_carrid1-low = ‘LH‘.
append s_carrid1.
* options限制 输入
SELECT-OPTIONS airline FOR wa_spfli-carrid NO INTERVALS "限制只能输入一个单元(LOW字段) 不显示字段的HIGH条件
NO-EXTENSION default g obligatory.” NO-EXTENSION 限制SELECT-OPTIONS只能输入一行数据 不显示多值选择按钮
NO-DISPLAY 禁止选择屏幕显示参数 显示控制
* 一行中的若干元素
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.
* 屏幕元素事件 按钮 及 USER-COMMAND
TABLES SSCRFIELDS.
SELECTION-SCREEN PUSHBUTTON /1(10) BUT1 " 10长度 20从左到右的位置 "或者 TEXT-020
USER-COMMAND CLI1.
SELECTION-SCREEN PUSHBUTTON /1(10) BUT2 " 10长度 20从左到右的位置 "或者 TEXT-020
USER-COMMAND CLI1.
INITIALIZATION.
BUT1 = ‘Button 1‘. "设置按钮的显示值
BUT2 = ‘Button 2‘. "设置按钮的显示值
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = ‘CLI1‘..
IF BUT1 = ‘Button 1‘.
ENDIF.
ENDIF.
START-OF-SELECTION.
* 执行按钮旁边加触点 点击改变屏幕
TABLES sscrfields.
PARAMETERS: p_carrid TYPE s_carr_id,
p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2. "此为两个触点定义 范围是1-5
INITIALIZATION.
sscrfields-functxt_01 = ‘@[email protected]‘ && ‘下载‘. " ‘@[email protected]‘ 为图像引用 可以在se38 RSTXICON 里面查看清单
sscrfields-functxt_02 = ‘上传‘. "此为两个触点的文本
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN‘FC01‘. “默认的 返回key
WHEN ‘FC02‘.
ENDCASE.
START-OF-SELECTION.
* 定义tab分页
*定义子屏幕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 = ‘测试‘.
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.
以上是关于SAP-ABAP SELECT-SCREEN的主要内容,如果未能解决你的问题,请参考以下文章