ABAP Help Document(22):10.3 Classic Lists

10.3 Classic lists

1.System Fields

sy-pagno:当前页码;

sy-linno:当前行;

sy-colno:当前列;

sy-linct:当前页每页行数,通过LINE-COUNT 在REPORT or NEW-PAGE中指定;

sy-linsz:行宽,通过LINE-SIZE 在REPORT or NEW-PAGE中指定;

sy-title:List header. Set in the text elements of a program or by SET TITLEBAR.

sy-srows:Current number of rows in the display window. Counting begins at 1.

sy-scols:Current number of columns in the display window. Counting begins at 1.

 

After List Events:

sy-lsind:List level of the current list;

sy-lilli:Absolute number of a selected row in the displayed list.

sy-listi:List level of the displayed list.

sy-lisel:Contents of the selected row.

sy-curow:Number of the row in the window, on which the cursor of the displayed list was positioned.

sy-cucol:Number of the column in the window, on which the cursor of the displayed list was positioned. Counting begins at 2.

sy-cpage:Number of the first displayed page of the displayed list. Counting begins at 1.

sy-staro:Number of the first row on the first displayed page of the displayed list. Counting starts at 1, the rows of the page header are included.

sy-staco:Number of the first displayed column of the displayed list. Counting begins at 1.

sy-ucomm:Function code that triggered the event on the displayed list.

sy-pfkey:GUI status of the list currently being displayed.

 

2.Creating Lists

语法:

WRITE {[AT] [/][pos][(len|*|**)]} dobj

      [UNDER other_dobj]

      [NO-GAP]

      [int_format_options]

      [ext_format_options]

      [list_elements]

      [QUICKINFO info].

/换行,pos指定输入位置,len指定输入长度,*,**根据dobj数据类型动态长度;

UNDER,在other_dobj下输出;

[int_format_options]:和write关键词format_options一致。

[LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED]

{ { [EXPONENT exp]

[NO-GROUPING]

[NO-SIGN]

[NO-ZERO]

[CURRENCY cur]

{ { [DECIMALS dec] [ROUND scale] } | [UNIT unit] } }

| { [ENVIRONMENT TIME FORMAT] [TIME ZONE tz] [STYLE stl] }

[USING { {NO EDIT MASK}|{EDIT MASK mask} }]

[ DD/MM/YY | MM/DD/YY | DD/MM/YYYY | MM/DD/YYYY | DDMMYY |MMDDYY |YYMMDD ].

[ext_format_options]:

[COLOR  {{{color [ON]}|OFF}|{= col}}]
[INTENSIFIED [{ON|OFF}|{= flag}]]
[INVERSE     [{ON|OFF}|{= flag}]]
[HOTSPOT     [{ON|OFF}|{= flag}]]
[INPUT       [{ON|OFF}|{= flag}]]
[FRAMES      [{ON|OFF}|{= flag}]]
[RESET] .

[list_elements]:

{AS CHECKBOX}

  | {AS ICON}

  | {AS SYMBOL}

  | {AS LINE}

示例:

FORM f_write_list.
  DATA:lv_text TYPE string VALUE 'hello welcome'.
  DATA:lv_col TYPE I VALUE 25.
  DATA:lv_len TYPE I VALUE 5.
  "输入长度最大255
  "CL_ABAP_LIST_UTILITIES计算list输出长度;
  ":可以不要,但是no gap必须要:
  "/换行
  WRITE: lv_text.
  WRITE: /25(5) lv_text.
  WRITE: AT /lv_col(lv_len) lv_text.
  "under:在指定other_obj输出
  WRITE: / lv_text UNDER lv_text.
  "no gap:无间隔输出
  WRITE: / lv_text NO-GAP,lv_text.
  "quick info
  WRITE / lv_text QUICKINFO 'quick info'.
ENDFORM.

FORM f_write_color.
  DATA:lv_text TYPE string VALUE 'hello world'.
  "header color
  WRITE: / lv_text COLOR COL_HEADING.
  "key color
  WRITE: / lv_text COLOR COL_KEY.
  "negative color
  WRITE: / lv_text COLOR COL_NEGATIVE.
  "normal color
  WRITE: / lv_text COLOR COL_NORMAL.
  "total
  WRITE: / lv_text COLOR COL_TOTAL.
  "增强背景色
  WRITE: / lv_text INTENSIFIED ON.
  "和上一颜色相反
  WRITE: / lv_text INVERSE ON.
  "热点点击
  WRITE: / lv_text HOTSPOT ON.
  "可输入
  WRITE: / lv_text INPUT ON.
  "frame?
  WRITE: / lv_text FRAMES ON.
  "reset格式
  WRITE: / lv_text RESET.
  "check box
  "只能和INPUT,NO-GAP,UNDER同时
  "字符串首字母为‘X’,'x'表示选中
  WRITE: / lv_text INPUT OFF AS CHECKBOX.
  WRITE: / lv_text AS CHECKBOX.
  "icon,
  TYPE-POOLS:ICON.
  WRITE: / '@1Q@' AS ICON.
  WRITE: / ICON_MAIL AS ICON.
  "symbol,
  TYPE-POOLS:SYM.
  WRITE: / SYM_CIRCLE AS SYMBOL.
  "line
  TYPE-POOLS:line.
  WRITE:/ line_top_left_corner AS LINE.
ENDFORM.

语法:

ULINE {[AT] [/][pos][(len)]} [NO-GAP].

划线。

语法:

FORMAT [COLOR {{{color [ON]}|OFF}|{= col}}]

[INTENSIFIED [{ON|OFF}|{= flag}]]

[INVERSE     [ {ON|OFF} | {= flag} ]]

[HOTSPOT     [ {ON|OFF} | {= flag} ]]

[INPUT       [{ON|OFF}|{= flag}]]

[FRAMES      [{ON|OFF}|{= flag}]]

[RESET].

设置format,

颜色:

 

Syntax of color

Value in col

Color

{ COL_BACKGROUND }

0

GUI-dependent

{ 1 | COL_HEADING }

1

Gray-blue

{ 2 | COL_NORMAL }

2

Light gray

{ 3 | COL_TOTAL }

3

Yellow

{ 4 | COL_KEY }

4

Blue-green

{ 5 | COL_POSITIVE }

5

Green

{ 6 | COL_NEGATIVE }

6

Red

{ 7 | COL_GROUP }

7

Purple

语法:

SET BLANK LINES {ON|OFF}.

是否显示write生成空白行

语法:

SKIP { [n] | {TO LINE line} }.

显示空行

语法:

NEW-LINE [NO-SCROLLING|SCROLLING].

新的一行

语法:

POSITION pos.

显示positon间隔

语法:
SET LEFT SCROLL-BOUNDARY [COLUMN col].

语法:

NEW-PAGE [page_options] [spool_options].

[page_options]:页面选项

WITH-TITLE|NO-TITLE]

    [WITH-HEADING|NO-HEADING]

    [LINE-COUNT page_lines]

    [LINE-SIZE width]

    [NO-TOPOFPAGE]

[spool_options]:

{ PRINT ON [NEW-SECTION] PARAMETERS pri_params

[ARCHIVE PARAMETERS arc_params] NO DIALOG }

| { PRINT OFF } ... .

pri_params,类型PRI_PARAMS;

arc_params,类型ARC_PARAMS;

使用function:GET_PRINT_PARAMETERS,获取打印参数;

语法:

HIDE dobj.

示例:

FORM f_write_line.
  "划线
  ULINE.
  ULINE AT 10(20).
  ULINE AT /10(20).
  "不显示后面空白
  SET BLANK LINES OFF.
  WRITE: / '    '.
  "空行
  SKIP 2.
  "scrolling?
  WRITE: / 'hello world'.
  NEW-LINE NO-SCROLLING.
  WRITE: / 'hello world'.

  "BACK占reserve位置输出
  RESERVE 2 LINES.
  WRITE: / 'line1'.
  WRITE: / 'line2'.
  WRITE: / 'line3'.
  BACK.
  WRITE: / 'back1'.
  WRITE: / 'back2'.

  "间隔距离
  WRITE: / 'position1'.
  POSITION 40.
  WRITE:  'position2'.

  "SET LEFT SCROLL-BOUNDARY,??
  DATA:lt_scarr TYPE TABLE OF scarr.
  DATA:ls_scarr LIKE LINE OF lt_scarr.
  SELECT * FROM scarr INTO TABLE lt_scarr.
  LOOP AT lt_scarr INTO ls_scarr.
    WRITE: / ls_scarr-carrid COLOR COL_KEY.
    SET LEFT SCROLL-BOUNDARY.
    WRITE: ls_scarr-carrname,
           ls_scarr-currcode,
           (40) ls_scarr-url.
  ENDLOOP.
  "HIDE??
  WRITE: / lv_date,lv_time.
  HIDE: lv_time.
ENDFORM

3.Process Lists

          操作内存Process Lists。

语法:

READ { {LINE line [{OF PAGE page}|{OF CURRENT PAGE}] [INDEX idx]}

| {CURRENT LINE} } [result].

[result]:

[LINE VALUE INTO wa]
[FIELD VALUE dobj1 [INTO wa1] dobj2 [INTO wa2] ...].

语法:

MODIFY { {LINE line [OF {PAGE page}|{CURRENT PAGE}] [INDEX idx]}

| {CURRENT LINE} }

[source].

[source]:

[LINE VALUE FROM wa]
[FIELD VALUE dobj1 [FROM wa1] dobj2 [FROM wa2] ...]
[LINE FORMAT ext_format_options]
[FIELD FORMAT dobj1 ext_format_options1 dobj2 ext_format_options2 ...].

语法:
SCROLL LIST [horizontal] [vertical] [INDEX idx].

[horizontal]:

{TO COLUMN col} | {{LEFT|RIGHT} [BY n PLACES]} ... .

[vertical]:

{TO {{FIRST PAGE}|{LAST PAGE}|{PAGE pag}} [LINE lin]}
  | {{FORWARD|BACKWARD} [n PAGES]}

滚动到目标页,行。

示例:

REPORT ZTOM_LEARNING9
  LINE-COUNT 100
  LINE-SIZE 100
  NO STANDARD PAGE HEADING.
SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW.
PARAMETERS page TYPE i.
SELECTION-SCREEN END OF SCREEN 500.
START-OF-SELECTION.
  DO 10000 TIMES.
    WRITE sy-index.
  ENDDO.
TOP-OF-PAGE.
  ULINE.
  WRITE sy-pagno.
  ULINE.
AT LINE-SELECTION.
  CALL SELECTION-SCREEN 500 STARTING AT 10 10.
  SCROLL LIST TO COLUMN sy-staco
              TO PAGE page LINE sy-staro. 

语法:

DESCRIBE LIST { {NUMBER OF {LINES|PAGES} n}

| {LINE linno PAGE page}

| {PAGE pagno page_properties} }

page_properties:

[INDEX idx].

[LINE-SIZE width]
[LINE-COUNT page_lines]
[LINES lines]
[FIRST-LINE first_line]
[TOP-LINES top_lines]
[TITLE-LINES title_lines]
[HEAD-LINES header_lines]
[END-LINES footer_lines]

4.Display Lists

语法:

LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN dynnr].

在屏幕PBO模块,结束处理当前dynpro sequence,执行List processor。

语法:

LEAVE LIST-PROCESSING.

立即结束List processor。

语法:

WINDOW STARTING AT col1 lin1
       [ENDING  AT col2 lin2].

显示List弹窗

语法:

SET PF-STATUS status [OF PROGRAM prog] [EXCLUDING fcode] [IMMEDIATELY].

设置GUI STATUS。

语法:

SET TITLEBAR title [OF PROGRAM prog] [WITH text1 ... text9].

设置TITLE。

语法:

SET CURSOR { { FIELD field LINE line [[DISPLAY|MEMORY] OFFSET off] }
| { LINE  line [[DISPLAY|MEMORY] OFFSET off] }
| { col lin } }.

设置光标

语法:

GET CURSOR { {FIELD field [field_properties]}

           | {LINE line [line_properties]} }.

[field_properties]:字段参数

[VALUE val] [LENGTH len]  [[DISPLAY|MEMORY] OFFSET off] [LINE lin].

[line_properties]:

[VALUE val] [LENGTH len] [[DISPLAY|MEMORY] OFFSET off].

获取光标

 

4.Printing Lists

          打开Print,

1.使用NEW-PAGE PRINT ON;

2.Excute+Print;

3.SUBMIT program TO SAP-SPOOL;

4.排程job,使用VIA JOB and TO SAP-SPOOL;

          print参数

1.打印dialog

通过function: SET_PRINT_PARAMETERS, GET_PRINT_PARAMETERS,设置和获取打印参数;

2.打印控制

语法:

SET MARGIN macol [marow].

设置margin,行,列。设置系统sy-macol,sy-marow。

语法:

PRINT-CONTROL { { formats|{FUNCTION code}  [LINE line] [POSITION col] }
| { INDEX-LINE index_line } }.

只在NEW-PAGE PRINT ON, SUBMIT TO SAP-SPOOL和使用Execute + Print打印有效。

formats

Print Control

Meaning

CPI cpi

CIcpi

Characters per inch

LPI lpi

LIlpi

Lines per inch

COLOR BLACK

CO001

Color black

COLOR RED

CO002

Color red

COLOR BLUE

CO003

Color blue

COLOR GREEN

CO004

Color green

COLOR YELLOW

CO005

Color yellow

COLOR PINK

CO006

Color pink

FONT font

FOfont

Font

LEFT MARGIN left

LMleft

Space from the left margin

SIZE siz

SIsiz

Font size

根据设备特殊参数在表TSP03,T022D。

Tcode: SPAD,输出设备,spool administration。

 

5.Event Block

Lists创建期间事件:

语法:

TOP-OF-PAGE [DURING LINE-SELECTION].

页头,"&1" - "&9"占位符对应系统参数sy-tvar0 - sy-tvar9。

语法:

END-OF-PAGE

Lists样式:

AT LINE-SELECTION

function code: PICK;

AT USER-COMMAND

1.function codes "PICK" and "PFnn" ("nn"stands for 01 to 24)不触发;

2.以下function code不触发;

 

Function code

Function

%CTX

Call a context menu

%EX

Exit

%PC

Save to file

%PRI

Print

%SC

Search for ...

%SC+

Find next

%SL

Search in office

%ST

Save to report tree

3.以下function code不触发;

BACK

Back

P-

Scroll to previous page

P--

Scroll to first page

P+

Scroll to next page

P++

Scroll to last page

PFILE name

Store list lines in a text file named "abap.lst" in standard character representation in the standard directory of the application server. If a name is entered using name, this is converted to lowercase letters and used as the file name.

PL-

Scroll to first line of the page

PL-n

Scroll n lines back

PL+

Scroll to last line of the page

PL+n

Scroll n lines up

PNOP

No effect

PP-

Scroll back one page

PP-n

Scroll n pages back

PP+

Scroll one page forward

PP+n

Scroll n pages forwad

PPn

Scroll to beginning of page n

PRI, PRINT

Print

PS--

Scroll to first column

PS++

Scroll to last column

PS-

Scroll one column to the left

PS-n

Scroll n columns to the left

PS+

Scroll one column to the right

PS+n

Scroll n columns to the right

PSn

Scroll to column n

PZn

Scroll to line n

RW

Cancel

AT PFnn(已经弃用)

设置事件

语法:

SET USER-COMMAND fcode.

设置用户自定义function code。

使用CL_ABAP_LIST_UTILITIES,计算Lists输出长度。

10.4 Messages

          维护message,Tcode: SE91,保存Table:T100。

          接口IF_T100_MESSAGE,创建类message。

          有效message type: "A", "E", "I", "S", "W", and "X"。

语法:
MESSAGE { msg | text } [message_options].

msg:message

{ tn }
| { tn(id) }
| { ID mid TYPE mtype NUMBER num }
| { oref TYPE mtype } ... .

text:

text TYPE mtype ... .

[message_options]:

{ {[DISPLAY LIKE dtype] [RAISING exception]} | [INTO text] }
 [WITH dobj1 ... dobj4].

示例:

Report test message-id test1.

message i000.

message i000(test1).

message id 'test1' type 'I' number '000'

示例:

DATA: oref TYPE REF TO cx_sy_arithmetic_error,

      text TYPE string.

TRY.

  CATCH cx_sy_arithmetic_error INTO oref.

    text = oref->get_text( ).

    MESSAGE text TYPE 'I'.

ENDTRY

示例:

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno INTO mtext

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 

系统变量:

Name

Meaning

sy-msgid

Contains the message-class after sending a message, and the value "00" after sending any text.

sy-msgno

Contains the message number after sending a message, and the value "001" after sending any text.

sy-msgty

Contains the identifier of the message type with which the message or the text was sent.

sy-msgv1 to sy-msgv4

Contain the content of the data objects specified after the addition WITH after sending a message (in order). After sending any text, they contain the first 200 characters of the data object text.

10.5 Conversion routines

    SAP内部格式转换,通过实现funciton module,

命名规则:

CONVERSION_EXIT_xxxxx_INPUT

CONVERSION_EXIT_xxxxx_OUTPUT

posted @ 2021-04-24 11:46  渔歌晚唱  阅读(174)  评论(0编辑  收藏  举报