ABAP之报表程序(PARAMETERS、SELECT-OPTIONS、SELECTION-SCREEN)

1.程序结构

REPORT ZMMR_TEST2 NO STANDARD PAGE HEADING LINE-SIZE 40  MESSAGE-ID zmm01.

NO STANDARD PAGE:设置为无基本标题。
LINE-SIZE 40 :设置报表宽度为40。
MESSAGE-ID zmm01 :设置消息。

2.PARAMETERS

REPORT ZMMR_TEST2 .
DATA:l_fname(20) TYPE c.
PARAMETERS:
    p_1 DEFAULT 'A',                           "DEFAULT 设置默认值。
    p_2 TYPE char10,                           "设置为10个字符
    p_3 TYPE c LENGTH 3 DEFAULT '123',         "定义长度
    p_4 TYPE p DECIMALS 2 DEFAULT '123.456789',"用于指定小数点位数
    P_5 LIKE sflight-carrid,                   "参照对象相同的数据类型
    p_6 MEMORY ID scl,                         "分配内存参数
    p_7 MATCHCODE OBJECT zcarrid,
    p_8 MODIF ID mid,                          "指定screen-group,用于分组控制画面属性
    p_9 NO-DISPLAY,                            "隐藏,不显示
    p_10 DEFAULT 'a' LOWER CASE,               "区分大小写
    p_11 OBLIGATORY,                            "必输字段
    p_12 AS CHECKBOX,                           "checkbox 显示
    P_13_1 RADIOBUTTON GROUP RADI,              "单选按钮
    P_13_2 RADIOBUTTON GROUP RADI,
    P_14(10) VISIBLE LENGTH 3 DEFAULT '1234567890',"设置显示长度
    P_15 LIKE sflight-carrid VALUE CHECK,          "继承表字段属性来检查check table的值(外部键)
    p_16 LIKE (l_fname),                            "
    p_17 LIKE sflight-carrid AS LISTBOX VISIBLE LENGTH 3,"显示为listbox
    p_18 AS CHECKBOX USER-COMMAND abc.                   "user-command用于复选款和单选按钮,执行事件。

3.SELECT-OPTIONS

SELECT-OPTIONS <seltab> FOR <f>.
SELECT * FROM SPFLI WHERE CARRID IN <seltab>.
REPORT ZMMR_TEST2 .
TABLES:SFLIGHT.
DATA:gs_scarr TYPE scarr.
DATA:gv_val   TYPE char20.
SELECT-OPTIONS:
    S_1 FOR sflight-carrid DEFAULT 'MU',                       "设置初始值
    S_2 FOR gs_scarr DEFAULT 'AA*' OPTION EQ SIGN I,           "OPTION:EQ(等于)、BT(区间值)、NB(区间值除外)、GE(>=)、LE(《=)、GT(>)、LT(<)、NE(不等于)
                                                               "SIGN:inclusive(I)、Exclusive(E)
    S_3 FOR gv_val   DEFAULT '1111' TO '9999',                 "指定区间值
    S_4 FOR gv_val   DEFAULT 'AAAA' TO 'ZZZZ' OPTION BT SIGN E,"此时option只能是BT  NB
    S_5 FOR sflight-carrid MEMORY ID scl,                      "指定MEMORY 参数
    S_6 FOR gv_val   MATCHCODE OBJECT zcarrid,                    
    S_7 FOR sflight-carrid MODIF ID car,
    S_8 FOR sflight-carrid NO-DISPLAY,                         "隐藏
    S_9 FOR sflight-carrid LOWER CASE,                         "区分大小写
    S_10 FOR sflight-carrid OBLIGATORY,                        "必输字段
    S_11 FOR sflight-carrid NO-EXTENSION,                      "删除复选框按钮
    S_12 FOR sflight-carrid NO INTERVALS,                      "删除high值
    S_13 FOR sflight-carrid VISIBLE LENGTH 1.                  "设置字段显示长度

 

4.SELECTION-SCREEN

SELECTION-SCREEN选项

SELECTION-SCREEN BEGIN OF LINE
SELECTION-SCREEN END OF LINE

将多个参数组合后显示在一行中
不能使用SELECT-OPTIONS、SELECTION-SCREEN SKIP n。

SELECTION-SCREEN SKIP n

追加n个空行

SELECTION-SCREEN ULINE
SELECTION-SCREEN ULINE /1(10)

追加Under line
SELECTION-SCREEN ULINE /1(10) :“/”指定行位置

SELECTION-SCREEN POSITION pos

在SELECTION-SCREEN BEGIN OF LINE中设置组件位置

SELECTION-SCREEN COMMENT fmt name

指定关于参数的描述
FMt代表 /pos(len)、pos(len)或者(len)
SELECTION-SCREEN COMMENT 1(10) text-001 FOR FIELD P_1.

SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom

在画面单机追加的按钮时,在AT SELECTTION-SCEEN中会保存SSCRFIELDS-UCOMN

SELECTION-SCREEN BEGIN OF BLOCK block.
SELECTION-SCREEN END OF BLOCK block.

形成PARAMETER、SELECT-OPTIONS等块
WITH FRAME:追加框架
TITLE title:追加框架的标题
NO INTERVALS:只显示块内SELECT-OPTIONS的LOW值

SELECTION-SCREEN FUNCTION KEY n

追加FUNCTION KEY.
要事先定义TABLES:SSCRFIRLDS.语句

SELECTION-SCREEN BEGIN OF TABBED BLOCK tblock

Tabstrip

SELECTION-SCREEN BEGIN OF SCREEN dynnr [AS SUBSCREEN]

定义子屏幕

 

REPORT ZMMR_CK_TEST2 .
TABLES:scarr,sscrfields.
SELECTION-SCREEN BEGIN OF LINE.   "将多个参数组合后显示在一行中
SELECTION-SCREEN COMMENT 1(10) text-001 FOR FIELD P_1.
PARAMETERS:P_1 LIKE SCARR-CARRID.

SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS:P_2 LIKE SCARR-CARRNAME.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 2.           "追加2个空行
SELECTION-SCREEN ULINE.            "追加Under line
SELECTION-SCREEN ULINE /1(10).     "/1(10)指定换行位置。
SELECTION-SCREEN ULINE POS_LOW(10).
SELECTION-SCREEN ULINE POS_HIGH(10).

SELECTION-SCREEN PUSHBUTTON /POS_LOW(10) TEXT-002 USER-COMMAND BTN01.
SELECTION-SCREEN BEGIN OF BLOCK BLOCK WITH FRAME TITLE TEXT-003.
  PARAMETERS:P_3 TYPE C.
  SELECT-OPTIONS:S_1 FOR SCARR-CARRID.
SELECTION-SCREEN END OF BLOCK BLOCK.

SELECTION-SCREEN BEGIN OF BLOCK BLOCK2 WITH FRAME TITLE TEXT-004 NO INTERVALS.
  PARAMETERS:P_4 TYPE C.
  SELECT-OPTIONS:S_2 FOR SCARR-CARRID.
SELECTION-SCREEN END OF BLOCK BLOCK2.
SELECTION-SCREEN FUNCTION KEY 1.

INITIALIZATION.
  MOVE 'FUNCTION KEY 1' TO SSCRFIELDS-FUNCTXT_01.

AT SELECTION-SCREEN.
  IF SSCRFIELDS-UCOMM = 'FC01'.
    MESSAGE 'YOU CLICKED FUNCTION KEY 1' TYPE 'I'.
  ENDIF.
  IF SSCRFIELDS-UCOMM = 'BTN01'.
    MESSAGE 'YOU CLICKED FUNCTION KEY BUTTON' TYPE 'I'.
  ENDIF.

 

posted @ 2020-07-08 22:38  cqyyck  阅读(1542)  评论(0编辑  收藏  举报