SKIP
SKIP { [n]
| {TO LINE line} }.
其实这些都是Online help,或者在ABAP环境中按F1呼出就可以查得到,但若不是仔细看,还真不知道有这么多细节,读者如果觉得有疑问,请参考源英文文档。
作用
将list cursor(可以理解为光标)位置下移一行或多行,或直接移直指定行数位置。
SKIP [n].
作用
该语句的作用是将list cursor移动n行,新起行的位置决定于变量n,n的data object是I。有如下情况:
n<=0 该语句被忽略
n未赋值 则按照 SKIP 1 执行
cursor位置的确定如下:
- 如果当前list cursor是由一条输出语句( WRITE, ULINE)确定,执行SKIP n 语句的效果为以该行为基准,list cursor的位置向下移动n行的开头。
- 如果当前list cursor是由一条定位语句( BACK, NEW-LINE, NEW-PAGE, SKIP)确定,执行SKIP n 语句的效果为以该行为基准,list cursor的位置向下移动n-1行的开头。
注意下列情况:
- 如果list cursor无法被放置在当前页,将新建一页,新建的页与当前页有相同的page footers。list cursor将被放置在page footers下第一行的开头。
- The statement is only executed at the start of the page if this page is the first in a list level, or it was generated using the statement NEW-PAGE. (暂不理解,未翻译)
注:
SKIP语句看上去是创建了n个空行,但这些空行是没有内容的,因此不能被Format语句格式化,只有Write语句结合SET BLANK LINES 才能产生可格式化的空行。
SKIP TO LINE line.
作用
令list cursor跳至当前页的某一行开头,由 line 值决定。line也是I类型,有下列情况:
line<=0 或 line >页长度 或遇到 NEW-PAGE SKIP后的TO LINE语句被忽略。SKIP执行,效果同SKIP.
注:
如果list cursor的位置在第一行使用SKIP TO LINE,而且这个list还有Standard page header,输出的结果是第一行会被standard header覆盖。If, however,the cursor is positioned using SKIP TO LINE in the lines of page headers and page footers that are defined for TOP-OF-PAGE and END-OF-PAGE, the page headers or footers are overwritten. (没看太明白,不翻译了)
原文:
SKIP
Syntax
SKIP { [n]
| {TO LINE line} }.
Variants:
1. SKIP [n].
2. SKIP TO LINE line.
Effect
Positions the list cursor under the current line or in any other line.
Variant 1
SKIP [n].
Effect
This statement positions the list cursor in relation to the current line. The new line is determined by the value of n. For n, a data object of type i is expected. If the value of n is smaller than or equal to 0, the statement is ignored. If n is not specified, the statement is executed as if n contains the value 1.
The cursor is positioned as follows:
- If the line of the current list cursor was set using an output statement ( WRITE, ULINE), the list cursor is set the first position of the line that is n lines under the current line.
- If the lines of the current list cursor was set using a positioning statement ( BACK, NEW-LINE, NEW-PAGE, SKIP), the list cursor is set in the current position in the line that is n minus 1 lines under the current line.
Note the following special conditions:
- If the list cursor cannot be positioned on the current page, a new page is created, which includes any page footers that the current page may have. The list cursor is positioned in the first position of the first line under the page header of the new page.
- The statement is only executed at the start of the page if this page is the first in a list level, or it was generated using the statement NEW-PAGE.
Note
In most application cases, this variant of the statement SKIP works as if it creates n blank lines. You need to ensure, however, that these blank lines have no content that can be formatted by the FORMAT statement. Formattable blank lines can only be generated by the WRITE statement in combination with SET BLANK LINES ON.
Variant 2
SKIP TO LINE line.
Effect
This statement positions the list cursor in the first position of the line on the current page whose number is determined by the value in line. For line, a data object of type i is expected. If the value of line is smaller than or equal to 0, or larger than the page length defined in sy-linct using the addition LINE-COUNT of the program-starting statement, or NEW-PAGE, the addition TO LINE is ignored and the statement SKIP without additions is executed instead.
Note
If the list cursor is positioned in the first list line using SKIP TO LINE, and the list has a standard page header, the output in the first line is overwritten by the standard header. If, however,the cursor is positioned using SKIP TO LINE in the lines of page headers and page footers that are defined for TOP-OF-PAGE and END-OF-PAGE, the page headers or footers are overwritten.
Example
The first SKIP statement generates a blank line for the event TOP-OF-PAGE. The second SKIP statement positions the list cursor in this line.
REPORT demo_skip NO STANDARD PAGE HEADING.
DATA sum TYPE i.
TOP-OF-PAGE.
SKIP.
ULINE.
START-OF-SELECTION.
DO 10 TIMES.
WRITE / sy-index.
sum = sum + sy-index.
ENDDO.
SKIP TO LINE 1.
WRITE: 'Numbers with sum' COLOR COL_HEADING,
sum COLOR COL_TOTAL.