You are on page 1of 7

Simple Reports

Write Operation
WRITE (see transaction LIBS for SAP guidelines using colors, symbols, icons etc. in
lists):
WRITE <f> [ <formatting options>].
<f> can be:
 any data object (variable, literal, constant);
 field symbol or formal parameter;
 text symbol like text-<nnn> or 'default text'(<nnn>), where <nnn> is text
symbol's Id.
Type-specific output (len=field length):
Type Standard output length Justified
C len left
D 8 left
F 22 right
I 11 right
N len left
P 2*len[+1] right
T 6 left
X 2*len left
Positioning output on the screen:
WRITE AT [/][<pos>][(<len>)] <f>.
<f> can be:
 / - new line;
 <pos>, <len> - numbers or variables up to 3 digits;
 AT can be omitted if <pos>, <len> are not variables.
If <len> is too short, fewer characters are displayed. Numeric fields are truncated on the
left and prefixed with an asterisk (*). All other fields are truncated on the right, but no
indication is given that the field is shorter.

Outputting symbols and icons on the screen:


WRITE <symbol-name> AS SYMBOL.
WRITE <icon-name> AS ICON.
<symbol-name> and <icon-name> are system-defined constants which are specified in
the include programs <SYMBOL> and <ICON> (<LIST> replaces both the above). The
angle brackets are part of the name.
To browse all available icons and symbols use pattern for the WRITE statement in the
ABAP/4 Editor. All icons can be viewed using the ICON transaction as well.
Lines and blank lines the screen:
ULINE [AT [/][<pos>][(<len>)]] [NO-GAP].
this is equivalent to WRITE [AT [/][<pos>][(<len>)]] SY_ULINE [NO-GAP].
WRITE [AT [/][<pos>]] SY-VLINE. or WRITE [AT [/][<pos>]] '|'.

ABAP Training Page 1 of 7


Simple Reports

SKIP [<n>].
SKIP TO LINE [<n>].
Note. WRITE / ' '. statement does not output blank line by default. To change default
setting use following statement:
SET BLANK LINES ON|OFF.
Outputting field content as checkbox:
WRITE <f> AS CHECKBOX.
If the first character of <f> is an "X", the checkbox is displayed filled. If the first
character is SPACE, the checkbox is displayed blank. The checkboxes that are created by
this statement are input enabled by default.
Outputting lines on the screen:
WRITE <f> AS LINE.
On list output, automatically links certain characters together to form continuous lines or
boxes, if there is no space between them:
 vertical lines, output with the system field SY-VLINE or using a field with the
contents "|" (vertical line);
 horizontal lines, output with the system field SY-ULINE or using a field with at
least 2 consecutive minus signs "--".
Exactly how each line segment is output (e.g. whether as straight line, corner, T-piece or
cross) depends on the adjoining characters.
The include <LINE> (or the more comprehensive include <LIST>) contains the relevant
identifiers for lines as constants, e.g. LINE_TOP_LEFT_CORNER,
LINE_BOTTOM_MIDDLE_CORNER.
FORMAT:
FORMAT <option1> [ON|OFF] <option2> [ON|OFF] ... .
FORMAT <option1>=<var1> <option2>=<var2> ... .
Effective from next output (WRITE or new line) operation until next event or turning
OFF. ON = default. <vari> should be of type I. If the <vari>=0, the variable has the same
effect as the OFF option. If WRITE statement follows the FORMAT statement, the
settings of the WRITE statement overwrite the corresponding settings of the FORMAT
statement for the current output.
 FORMAT COLOR <n> [ON] INTENSIFIED [ON|OFF] INVERSE [ON|
OFF].
Does not work for lines. If INVERSE is used, the INTENSIFIED has no effect. Has no
effect on input fields.

ABAP Training Page 2 of 7


Simple Reports

vari Symbol name Color


OFF COL_BACKGROUND Background (GUI-specific)
1 COL_HEADING Headers (grayish blue)
2 COL_NORMAL List body (bright gray)
3 COL_TOTAL Totals (yellow)
4 COL_KEY Key columns (bluish green)
5 COL_POSITIVE Positive threshold value (green)
6 COL_NEGATIVE Negative threshold value (red)
7 COL_GROUP Control levels (violet)


Call the SHOWCOLO report in any system for demonstration of colors in lists.
 SUMMARY. this is equivalent to FORMAT INTENSIFIED ON.
DETAIL. this is equivalent to FORMAT INTENSIFIED OFF.
 FORMAT HOTSPOT [ON|OFF].
Affects the display format of the mouse pointer and the effect of the mouse single click:
If you drag the mouse pointer over list areas which are output with the format
...HOTSPOT (lines or fields), the mouse pointer switches from its standard display
format (usually an arrow) to the format of a hand with an outstretched index finger. If you
then click once, the effect is like double-clicking or pressing the function key F2 (AT
LINE-SELECTION). Has no effect on input fields.
 FORMAT INPUT [ON|OFF].
Determines whether the user can enter data. See READ LINE.
 FORMAT RESET.
The same as FORMAT COLOR OFF INTENSIFIED OFF INVERSE OFF
HOTSPOT OFF INPUT OFF.

ABAP Training Page 3 of 7


Simple Reports

Define Structure
List Width:
REPORT <report> LINE-SIZE <n>.
n=0 : standard list. List cannot be wider than 255 (132 for most printers). SY-LINSZ
contains the current line size.
To adapt the line size to the current window width, set <n> to SY-SCOLS. SY-SCOLS
contains the number of characters of a line of the current window.
Page Length:
REPORT <report> LINE-COUNT <length>[(<n>)].
n - number of reserved for footer lines. length=0 : standard list. SY-LINCT contains the
current page length or 0 if standard page.
To adapt the page length to the current window length, set <length> to SY-SROWS. SY-
SROWS contains the number of lines of the current window.
Individual Page Header:
REPORT <report> [NO STANDARD PAGE HEADING].
....
TOP-OF-PAGE [DURING LINE-SELECTION].
WRITE... .
List processing event that is executed before the first data is output on a new page.
Without the addition ... DURING LINE-SELECTION, processed only when generating
basic lists, not when creating secondary lists. Only executed before outputting the first
line on a new page - not triggered by a NEW-PAGE statement.
During the event TOP-OF-PAGE, you can also fill the system fields SY-TVAR0...SY-
TVAR9 with values that should replace eventual placeholders &0...&9 in the standard
page header.
Individual Page Footer:
REPORT <report> LINE-COUNT <length>(<n>).
....
END-OF-PAGE.
WRITE... .
END-OF-PAGE processed only if n>0. If you explicitly specify a new page with NEW-
PAGE, END-OF-PAGE is ignored.
Page Break:
NEW-PAGE [PRINT ON ...].
 ends the current page and increased SY-PAGNO by 1;
 does not trigger the END-OF-PAGE event.
NEW-PAGE [NO-TITLE|WITH-TITLE] [NO-HEADING|WITH-HEADING].
 used to suppress or display the standard header and/or columns headers on all
pages to come. default both: WITH for basic and NO for secondary lists;
 does not affect the display of a page header defined at the event TOP-OF-PAGE.
NEW-PAGE LINE-COUNT <length>.
length=0 : standard list. Can be variable.

ABAP Training Page 4 of 7


Simple Reports

NEW-PAGE LINE-SIZE <n>.


n=0 : standard list. Can be variable. Within a list level, that is, if the next page is not the
beginning of a new list level, the system ignores the LINE-SIZE option.
RESERVE <n> LINES.
Triggers a page break if less than <n> free lines are left on the current list page between
the last output and the page footer. <n> can be a variable. Before starting a new page, the
system processes the END-OF-PAGE event. RESERVE only takes effect if output is
written to the subsequent page. No blank pages are created.
Scrolling:
common notes.
 SCROLL works for completed lists only. If you use SCROLL before the first
output statement of a list, it does not affect this list. If you use SCROLL after the first
output statement of a list, it affects the entire list, that is, all subsequent output statements
as well;
 While creating a secondary list, a SCROLL statement without INDEX option
always refers to the previously displayed list on which the interactive event occurred
(index SY-LISTI);
 Only when creating the basic list does the SCROLL statement refer to the
currently created list;
 You can use the INDEX option to explicitly scroll on existing list levels. To do
this, the lists need not be displayed. When the user displays the list again, it is scrolled to
the specified position. If the specified list level does not exist, the system sets SY-
SUBRC to 8;
 If, during an interactive event, you want to scroll through the list you are currently
creating, use SY-LSIND as the index in the SCROLL statement. Note that a manipulation
of SY-LSIND takes effect only at the end of the event on the created list, independent of
where you place the statement in the processing block. If you want to set the list level
explicitly, you must manipulate SY-LSIND in the last statement of the processing block
to make sure that a SCROLL statement within the processing block accesses the correct
list;
 Another way of scrolling interactive lists from within the program is to use the
SET USER-COMMAND statement in connection with the corresponding system-defined
function codes;
 SY-SUBRC = 0 : Ok; = 4 : scrolling was not possible (exit boundaries); = 8 : list
level does not exist.
SCROLL LIST FORWARD|BACKWARD [INDEX <index>].
vertical scrolling window by window
SCROLL LIST TO {FIRST PAGE|LAST PAGE|PAGE <n>} [INDEX <index>]
[LINE <line>].
SCROLL LIST FORWARD|BACKWARD <n> PAGES [INDEX <index>].
vertical scrolling by pages
SCROLL LIST LEFT|RIGHT [INDEX <index>].
horizontal scrolling to margins
SCROLL LIST TO COLUMN <n> [INDEX <index>].
SCROLL LIST LEFT|RIGHT BY <n> PLACES [INDEX <index>].
horizontal scrolling by columns

ABAP Training Page 5 of 7


Simple Reports

SET LEFT SCROLL-BOUNDARY [COLUMN <n>].


Only the part to the right from {current column|column <n>} will be scrolled
horizontally. Applies to the entire current page, and only to it. To set the same scrollable
area for all pages of a list, use, for example, at the TOP-OF-PAGE event.
NEW-LINE NO-SCROLLING.
Excludes the line following the statement from horizontal scrolling (for example, title
line).
NEW-LINE SCROLLING.
This statement makes sense only if after NEW-LINE NO-SCROLLING no line was
output.
Displaying Lists in Dialog Windows.
WINDOW STARTING AT <left> <upper> [ENDING AT <right> <lower>].
Causes the current list (index SY-LSIND) to be displayed in a dialog window. If <upper>
= 0, the list appears on a fullscreen. By default, the system uses the values of the lower
right corner of the window on which the event occurred. If the width of the dialog
window is smaller than the width of the preceding list, the system creates a horizontal
scroll bar on the dialog window. To prevent that, you must adapt the width of the
secondary list to the width of the dialog window by using the following statement: NEW-
PAGE LINE-SIZE <width>.
Dialog window has not a menu bar or a standard toolbar. Standard application toolbar at
the lower margin has functions PRI, %SC, %SC+, and RW.
Positioning the output
For the current output position, refer to the system fields
 SY-COLNO - the current column;
 SY-LINNO - the current line.
POSITION <column>.
Sets horizontal output position. Se also WRITE AT and SKIP TO LINE for vertical
output position.
BACK.
Subsequent output appears beneath the page header or to the first line of a block of lines
defined with the RESERVE, if used. If you specify BACK at the TOP-OF-PAGE event,
the system does not set the output position to beneath the entire page header, but only to
beneath the standard page header. Any output written now overwrites the self-defined
page header specified at TOP-OF-PAGE.
SET TITLEBAR:
SET TITLEBAR <titlebar> [WITH <f0> <f1> ... <f9>].
Sets a screen title. A set title remains valid within a transaction until you call SET
TITLEBAR again. SY-TITLE (can be up to 70 characters long) contains the current
screen title. Allows you to build up to 9 parameters into the header, using the variables
&1 to &9.
Retrieving List Attributes:
You should use this key word only in exceptional cases (e.g. when editing an 'anonymous'
list in a program other than that which generated the list). In all other cases, you should
save the relevant values when you generate the list. Take care when attempting to retrieve
the list attributes being set up (...INDEX SY-LSIND), since some attributes (number of
pages, number of lines, ...) may not have been updated yet.

ABAP Training Page 6 of 7


Simple Reports

DESCRIBE LIST NUMBER OF LINES|PAGES <n> [INDEX <index>].


Returns the number of lines|pages in the list. SY-SUBRC=0 : Ok, <>0 : list does not
exists.
DESCRIBE LIST LINE <nl> PAGE <n> [INDEX <index>].
Returns the number of the page for the line <nl> in the list. SY-SUBRC=0 : Ok, 4 : line
does not exists, 8 : list does not exists.
DESCRIBE LIST PAGE <np> <options> [INDEX <index>].
Returns the attributes of the page <np> in the list. SY-SUBRC=0 : Ok, 4 : page does not
exists, 8 : list does not exists. <options>:
 LINE-SIZE <n> - page width;
 LINE-COUNT <n> - page length;
 LINES <n> - number of displayed lines;
 FIRST-LINE <n> - absolute number of the first line;
 TOP-LINES <n> - number of lines output by page header processing (i.e.
standard title + column headers + TOP-OF-PAGE);
 TITLE-LINES <n> - number of lines output as standard title lines by page
header processing (see NEW-PAGE).
Note. The value of TITLE-LINES is contained in TOP-LINES;
 HEAD-LINES <n> - number of lines output as column headers by page header
processing (see NEW-PAGE).
Note. The value of HEAD-LINES is contained in TOP-LINES;
 END-LINES <n> - number of lines output by page footer processing (see END-
OF-PAGE);

ABAP Training Page 7 of 7

You might also like