选择屏幕语法

选择屏幕程序语法

1.   PARAMETERS(见1.6)

SSCRFIELDS选择屏幕上的字段

USER-COMMAND fcode在使按钮能正常工作之前,必须使用TABLES sscrfields.语句来为ABAP数据词典中的SSCRFIELDS结构来定义接口工作区。当用户点击按钮后会触发AT SELECTION-SCREEN事件,并且function code fcode会存储到sscrfields-ucomm字段中。

PARAMETERS: A1(10) TYPE C,

 A2      TYPE I.

WRITE: / A1,/ A2.

2.SELECT-OPTIONS

SELECT-OPTIONS selcrit FOR {dobj|(name)}
               [screen_options]
               [value_options]
               [ldb_options].

l  screen_options

... [OBLIGATORY|NO-DISPLAY]
    [VISIBLE LENGTH vlen]
    [NO-EXTENSION] “限制选择表为单行,元素输入后面不会出现按钮。
    [NO INTERVALS] ” 只会出现LOW字段,
    [MODIF ID modid] ... . 选择屏幕中的参数选项 MEMORY ID的作用就等同于对话屏幕中的SET/GET Parameter,它们是作用是相同的(都是针对SAP Memory),只不过一个用于选择屏幕中,一个用于对话屏幕。

l  value_options

... [DEFAULT val1 [TO val2] [OPTION opt] [SIGN sgn]]
    [LOWER CASE]
    [MATCHCODE OBJECT search_help]
    [MEMORY ID pid] ... .

SELECT-OPTIONS selcrit FOR {dobj|(name)}

该语句会生成一个名为selcrit选择条件内表,行结构类型如下的全局内表:

DATA:BEGIN OF selcrit OCCURS 0,
  sign(1), “sign字段是长度为1的C类型数据。它是标志位,允许值为IE
  option(2),” OPTION字段的数据类型是C,长度为2,OPTION包含选择运算符”
  low LIKE mara-matnr, low字段的数据类型与f类型相同,该值为范围选择指定了下界
  high LIKE mara-matnr, “HIGH字段的数据类型与f类型相同,该值为范围选择指定了上界
END OF selcrit.

语法示例:

s_werks FOR marc-werks OBLIGATORY DEFAULT 1001 to 1007 SIGN I OPTION BT 

3.SELECT-SCREEN.

SELECTION-SCREEN - BEGIN OF SCREEN.

  1. 1.  SELECTION-SCREEN BEGIN OF SCREEN dynnr [TITLE title]
                                           [AS WINDOW].
    SELECTION-SCREEN END OF SCREEN dynnr
  2. SELECTION-SCREEN BEGIN OF SCREEN dynnr AS SUBSCREEN
                            [NO INTERVALS] 创建的框架中限制SELECT只有一个输入项
                            [NESTING LEVEL n]. adjust the width of the subscreen if it is to be included in a tabstrip control in one or more frames. You must specify n directly as a number between 0 and 4.

SELECTION-SCREEN END OF SCREEN dynnr.

SELECTION-SCREEN - screen_elements


1. SELECTION-SCREEN SKIP [n] [ldb_additions]. 空格n行

2. SELECTION-SCREEN ULINE [[/][pos](len)] [MODIF ID modid]
                         [ldb_additions]. 位置与长度,划出横线,必须用在BLOCK中才能生效
3. SELECTION-SCREEN COMMENT [/][pos](len)
                           {text|{[text] FOR FIELD sel}}
                           [VISIBLE LENGTH vlen]
                           [MODIF ID modid]
                           [ldb_additions].
4. SELECTION-SCREEN PUSHBUTTON [/][pos](len) button_text 位置与长度,名字
                         USER-COMMAND ucom 指定的字符代码,当用户在选择屏幕上触发按钮时
                              [VISIBLE LENGTH vlen]
                              [MODIF ID modid]
                              [ldb_additions].
5. SELECTION-SCREEN BEGIN OF LINE. 将所生成的屏幕元素控制在一行。
  [SELECTION-SCREEN POSITION pos [ldb_additions]].BLOCK中产生空格。
  SELECTION-SCREEN END OF LINE.
6. SELECTION-SCREEN BEGIN OF BLOCK block
                           [WITH FRAME [TITLE title]]带标题框架
                           [NO INTERVALS].
  SELECTION-SCREEN END OF BLOCK block.
7. SELECTION-SCREEN BEGIN OF TABBED BLOCK tblock FOR n LINES.
  ...
  SELECTION-SCREEN TAB (len) tab USER-COMMAND ucom
                   [DEFAULT [PROGRAM prog] SCREEN dynnr].
  ...
  SELECTION-SCREEN END OF BLOCK tblock.
8. SELECTION-SCREEN FUNCTION KEY n [ldb_additions]. the application toolbar contains five inactive pushbuttons, to which the function codes FC01 to FC05 are assigned. This statement activates the pushbutton of the function code FC0n, whereby a value between 1 and 5 must be entered for n.

 

语法示例:

 

示例一:


SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
PARAMETERS: p1 TYPE c LENGTH 10,
            p2 TYPE c LENGTH 10,
            p3 TYPE c LENGTH 10.
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
PARAMETERS: q1 TYPE c LENGTH 10,
            q2 TYPE c LENGTH 10,
            q3 TYPE c LENGTH 10.
SELECTION-SCREEN END OF SCREEN 200.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES,
                  TAB (20) button1 USER-COMMAND push1,
                  TAB (20) button2 USER-COMMAND push2,
                  END OF BLOCK mytab.

INITIALIZATION.
  button1 = 'Selection Screen 1'.
  button2 = 'Selection Screen 2'.
  mytab-prog = sy-repid.
  mytab-dynnr = 100.
  mytab-activetab = 'PUSH1'.
AT SELECTION-SCREEN.
  CASE sy-dynnr.  “当前屏幕号
    WHEN 1000.
      CASE sy-ucomm.
        WHEN 'PUSH1'.
          mytab-dynnr = 100.
        WHEN 'PUSH2'.
          mytab-dynnr = 200.
        WHEN OTHERS.  
      ENDCASE.
  ENDCASE.

 

 

 

 

 

示例二:

TYPE-POOLS icon.
TABLES sscrfields.            “选择屏幕上的字段
DATA functxt TYPE smp_dyntxt. “
动态文本的程序接口
PARAMETERS: p_carrid TYPE s_carr_id,
            p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1,   “FC01
                           FUNCTION KEY 2.   “FC02
INITIALIZATION.
  functxt-icon_id   = icon_ws_plane.
  functxt-quickinfo = 'Preselected Carrier'.
  functxt-icon_text = 'LH'.
  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'.
    WHEN OTHERS.
  ENDCASE.

 

SELECTION-SCREEN INCLUDE

(调用已经存在的屏幕元素)


PARAMETERSpara
   [OBLIGATORY [OFF]]
   [MODIF ID modid]
   [ID id].

 

 

 

 

SELECT-OPTIONS selcrit
 [OBLIGATORY [OFF]]
 [NO INTERVALS [OFF]]
 [NO-EXTENSIONS

[OFF]]
 [MODIF ID modid]
 [ID id].

 

COMMENT [/][pos](len) text
[FOR FIELD sel]
[MODIF ID modid]
[ID id].

 
PUSHBUTTON [/][pos](len) button_text
[USER-COMMAND ucom]
[MODIF ID modid]
[ID id].


BLOCKS block [ID id].

 


 

 


语法示例:

 

SELECTION-SCREEN: BEGIN OF BLOCK block,
                  COMMENT /1(40) text,
                  ULINE.
PARAMETERS: p1(10) TYPE c,
            p2(10) TYPE c,
            p3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK block.
SELECTION-SCREEN: BEGIN OF SCREEN 500 AS WINDOW,
                  INCLUDE BLOCKS block,
                  END OF SCREEN 500.
INITIALIZATION.
  text = 'Standard Selection'.
START-OF-SELECTION.
  CALL SELECTION-SCREEN '0500' STARTING AT 10 10. “调用屏幕

 

CALL SELECTION-SCREEN

CALL SELECTION-SCREEN dynnr
                      [STARTING AT col1 lin1
                      [ENDING   AT col2 lin2]]
                      [USING SELECTION-SET variant].

CALL SELECTION-SCREEN '0500' STARTING AT 10 10. “调用屏幕

AT SELECTION-SCREEN

是PAI处理,选择屏幕显示之后,用来响应回车,F8,F1,F4等事件。
      (1)选择屏幕事件,此处声明的变量是局部变量。
     (2)check sy-ucomm 判断用户命令。
     (3)在这个事件响应中,可以对屏幕字段进行有效性检验等,但无法修改选择屏幕。

 

{ OUTPUT }  屏幕输出时的各屏幕元素值的管控(PBO处理,在选择屏幕显示之前就被调用;响应屏幕上的事件,用户回车或F8后也被调用;通过modify screen可以修改选择屏幕字段)
  | { ON {para|selcrit} } 检查具体输入字段是否完整或正确


  | { ON END OF selcrit }
  | { ON BLOCK block }框架的触发事件(控制框架中的屏幕元素值的输入)
  | { ON RADIOBUTTON GROUP radi }单选按钮事件,必须进行整体输入检查
  | { }
  | { ON {HELP-REQUEST|VALUE-REQUEST} VALUE-<F4>键时触发HELP-<F1>键时键
  |   FOR {para|selcrit-low|selcrit-high} }检查具体输入字段是否完整或正确
  | { ON EXIT-COMMAND }.响应"BACK","CANCEL","EXIT"等事件

语法示例:

PARAMETERS p_carrid TYPE spfli-carrid.

AT SELECTION-SCREEN ON p_carrid.

IF p_carrid IS INITIAL.

上一篇:ABAP DEMO 年月的搜索帮助


下一篇:富文本编辑器直接从 word 中复制粘贴公式