ABAP中SELECTION-SCREEN用法

SAP-ABAP SELECT-SCREEN 的几个用法

 

实例1:
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.

  comm1 ='Auswahlknopfgruppe 1'.


4 SELECTION-SCREEN SKIP 1.
跳过一行。类似于用WRITE写Report时的SKIP 1.也可以跳过多行。

以下是 屏幕上画横线

  SELECTION-SCREEN ULINE /1(50).

5.内存记忆 留有上次输入过的记录

parameters test(16) type c memory id rid.

6.检查输入值 如果不在表中 不用做代码检查了

PARAMETERS p_carr TYPE spfli-carrid OBLIGATORY VALUE CHECK.

7.复选框

PARAMETERS: a AS CHECKBOX,
            b AS CHECKBOX DEFAULT 'X'.

8.单选框

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'.

9.屏幕动作变化 引起屏幕变化: modif id 起作用

举例:

report a.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME title TEXT-003.
PARAMETERS:
  P_1 TYPE C RADIOBUTTON GROUP DATE
                        DEFAULT 'X'
                        USER-COMMAND FLAG,    "重要*
  P_2 TYPE C RADIOBUTTON GROUP DATE,
  P_3 TYPE C RADIOBUTTON GROUP DATE,
  P_4 TYPE C RADIOBUTTON GROUP DATE
  .
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME  title TEXT-004.
SELECTION-SCREEN: BEGIN OF LINE,
                  COMMENT 6(10) TEXT-001.
  PARAMETERS: GP_IPDAT TYPE SY-DATUM MODIF ID BL1, "重要*
     GP_2 TYPE SY-DATUM MODIF ID BL2 .  "重要*
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN: BEGIN OF LINE,
                  COMMENT 8(60) TEXT-005,
                  END OF LINE,
                  BEGIN OF LINE,
                  COMMENT 8(60) TEXT-006,
                  END OF LINE.
SELECTION-SCREEN END OF BLOCK BL2.
"在AT SELECTION-SCREEN中循环SCREEN系统变量,把需要修改的画面元素的属性进行相应的修改
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF P_1 = 'X' AND SCREEN-GROUP1 = 'BL1'.
      SCREEN-INPUT = '0'.
      CLEAR GP_IPDAT.
    ENDIF.
    IF P_2 = 'X' AND SCREEN-GROUP1 = 'BL1'.
      SCREEN-INPUT = '1'.
    ENDIF.
        IF P_3 = 'X' AND SCREEN-GROUP1 = 'BL2'.
      SCREEN-ACTIVE = '0'.
      CLEAR GP_IPDAT.
    ENDIF.
    IF P_4 = 'X' AND SCREEN-GROUP1 = 'BL2'.
      SCREEN-ACTIVE = '1'.
    ENDIF.

    MODIFY SCREEN.
  ENDLOOP.

10.ranges 使用方法

ranges s_carrid1 for spfli-carrid.

s_carrid1-sign   = 'I'.
s_carrid1-option = 'EQ'.
s_carrid1-low    = 'LH'.

append s_carrid1.

11. options限制 输入

SELECT-OPTIONS airline FOR wa_spfli-carrid NO INTERVALS
                                           NO-EXTENSION  default g obligatory.”

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 屏幕元素事件 按钮  及 new window USER-COMMAND

TABLES sscrfields.

DATA flag(1) TYPE c.

SELECTION-SCREEN:
  BEGIN OF SCREEN 500 AS WINDOW TITLE tit,
    BEGIN OF LINE,
      PUSHBUTTON 2(10) but1 USER-COMMAND cli1,
      PUSHBUTTON 12(10) text-020 USER-COMMAND cli2,
    END OF LINE,
    BEGIN OF LINE,
      PUSHBUTTON 2(10) but3 USER-COMMAND cli3,
      PUSHBUTTON 12(10) text-040 USER-COMMAND cli4,
    END OF LINE,
  END OF SCREEN 500.

AT SELECTION-SCREEN.

  MESSAGE i888(sabapdocu) WITH text-001 sscrfields-ucomm.
  CASE sscrfields-ucomm.
    WHEN 'CLI1'.
      flag = '1'.
    WHEN 'CLI2'.
      flag = '2'.
    WHEN 'CLI3'.
      flag = '3'.
    WHEN 'CLI4'.
      flag = '4'.
  ENDCASE.

START-OF-SELECTION.

  tit  = 'Four Buttons'.
  but1 = 'Button 1'.
  but3 = 'Button 3'.

  CALL SELECTION-SCREEN 500 STARTING AT 10 10.

  CASE flag.
    WHEN '1'.
      WRITE / 'Button 1 was clicked'.
    WHEN '2'.
      WRITE / 'Button 2 was clicked'.
    WHEN '3'.
      WRITE / 'Button 3 was clicked'.
    WHEN '4'.
      WRITE / 'Button 4 was clicked'.
    WHEN OTHERS.
      WRITE / 'No Button was clicked'.
  ENDCASE.

14  执行按钮旁边加触点 点击改变屏幕

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'. “默认的 返回key
      p_carrid = 'LH'.
      p_cityfr = 'Frankfurt'.
    WHEN 'FC02'.
      p_carrid = 'UA'.
      p_cityfr = 'Chicago'.
  ENDCASE.

START-OF-SELECTION.
  WRITE / '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.

  APPEND: 'PRIN' TO itab,
          'SPOS' TO itab.

  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
       EXPORTING
            p_status  = sy-pfkey
       TABLES
            p_exclude = itab.

16.选择屏幕 事件何时触发(有待研究)实例2

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:  test1(10) TYPE c,
             test2(10) TYPE c.
SELECTION-SCREEN END OF BLOCK block1.

PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',
            r2 RADIOBUTTON GROUP rad1.

AT SELECTION-SCREEN.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'.

AT SELECTION-SCREEN OUTPUT.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'OUTPUT'.

AT SELECTION-SCREEN ON sel_opt1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON SEL_OPT1'.

AT SELECTION-SCREEN ON test1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON TEST1'.

AT SELECTION-SCREEN ON test2.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON TEST2'.

AT SELECTION-SCREEN ON END OF sel_opt1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON END OF SEL_OPT1'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR sel_opt1-low.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON HELP-REQUEST FOR SEL_OPT1-LOW'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR sel_opt1-high.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON HELP-REQUEST FOR SEL_OPT1-HIGH'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR test1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON HELP-REQUEST FOR TEST1'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR test2.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON HELP-REQUEST FOR TEST2'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_opt1-low.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON VALUE-REQUEST FOR SEL_OPT1-LOW'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_opt1-high.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON VALUE-REQUEST FOR SEL_OPT1-HIGH'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR test1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON VALUE-REQUEST FOR TEST1'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR test2.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON VALUE-REQUEST FOR TEST2'.

AT SELECTION-SCREEN ON BLOCK block1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON BLOCK BLOCK1'.

AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.
  MESSAGE i888 WITH 'AT SELECTION-SCREEN'
                    'ON RADIOBUTTON GROUP RAD1'.

 

 

 

 

转载自:http://blog.tianya.cn/blogger/post_show.asp?BlogID=1271361&PostID=14936563

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值