WRITE f.
1. ... [AT]
[/][pos][(len|*|**)
(position and length specification)
2.
... option (formatting option)
3.
... fmt (field-by-field display format)
4.
... AS CHECKBOX (output as a checkbox)
5.
... AS SYMBOL (output as a symbol)
6.
... AS ICON (output as an icon)
7.
... AS LINE (output as a line)
8. ... QUICKINFO g (output as a tool tip)
Outputs an elementary field f in the correct format for its type in the current list.
DATA SPFLI_WA TYPE SPFLI.
DATA N TYPE I VALUE 123.
...
WRITE N.
WRITE SPFLI_WA-FLTIME.
FIELD-SYMBOLS <CF> TYPE ANY.
ASSIGN 'NEW YORK' TO <CF>.
WRITE <CF>.
WRITE: '---->', SPFLI_WA-DISTANCE.
WRITE: TEXT-001, SPFLI_WA-ARRTIME.
or
WRITE: 'Time:'(001), SPFLI_WA-ARRTIME.
As in all ABAP statements, text symbols can be addressed in two different
ways (TEXT-001 or 'Time:'(001)).
If no explicit position is specified for a field on a new line, it is output on the left (in column
1). Otherwise, output is one column removed from the previously output field. If a field does not fit
on one line, a new line is started.
You can perform explicit positioning with a position and length
specification (see addition 1) or with ABAP/4 statements (e.g. POSITION).
In this case, the field is always output at the defined position, even if the line is not quite long
enough for it to fit completely.
If a field is too long to fit completely on the line, the excess
characters are truncated.
When you explicitly position fields on a list, you should almost always
use the ... LINE-SIZE (for the corresponding REPORT->>
or NEW-PAGE NEW-PAGE->
statement); otherwise, the width of the list will depend on the current width of the display window, the font used, and other such factors that can lead to the list display being truncated.
System fields that are useful when generating lists are documented in System Fields for Lists.
... [AT] [/][pos][(len|*|**) (position and length specification before the field)
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Incorrect Dynamic Position Specifications.
After AT, you can specify the output position and output length of the current WRITE statement. Any output that already exists at the output position is overwritten in the list buffer in the output length of the new output. After overwriting an existing output, the system sets the list cursor to the next position and not the one after.
The elements of the position and length specification /, pos and len or * or ** must be listed in the specified order and without spaces. If no named data objects are specified in the position and length specification, the AT addition can be omitted.
Data Type | * | ** |
c | Number of columns required to display the entire contents in the list; closing blanks are ignored. In Unicode systems, this length can be greater than the implicit length. | Double the length of the data object |
string | implicit length | Double the number of contained characters |
n, x, xtring | implicit length | implicit length |
d | 10 | 10 |
t | 8 | 8 |
i, f, p | Length required to display the current value including thousand separators; the system uses the value that exists after the use of any of the additions CURRENCY, DECIMALS, NO-SIGN, ROUND, or UNIT. | Length required to display the maximum possible values of these types including prefixes and thousand separators; the system uses the value that exists after the use of any of the additions CURRENCY, DECIMALS, NO-SIGN, ROUND, or UNIT. |
If a conversion routine is executed with reference to a data type in the ABAP Dictionary, the routine
is executed either for the length defined forlen or for
the output length defined in the ABAP Dictionary for*
or **, depending on which is specified. If you specify
* or **, the output length is determined from the result of the conversion routine according the rules above.
DATA: WORD(16), VALUE '0123456789ABCDEF',
COL TYPE I VALUE 5,
LEN TYPE I VALUE 10.
WRITE AT / WORD. "new
line
WRITE AT 5 WORD. "column 5
WRITE
AT (10) WORD. "output length 10
WRITE AT /5(10) WORD.
"new line, column 5, length 10
WRITE AT COL WORD. "column
= contents of COL
WRITE AT (LEN) WORD. "output length = contents
of LEN
WRITE AT /COL(LEN) WORD. "new line, column = contents of COL
"output length = contents of LEN
... option (formatting option)
You can modify the output of the field f by using one of the special formatting options.
... fmt (output format by field)
Outputs the field with the specified output formats (color, intensity, ready for input, ...).
You
can use the same output options as for FORMAT. If no specifications are
made, the field is output with the standard formats or with the format set by a preceding FORMAT statement.
DATA F.
FORMAT INTENSIFIED OFF INPUT.
WRITE F INPUT OFF INVERSE COLOR 3.
The format specifications with WRITE apply only for output
of the field f. They modify the currently valid format
for this field. This means that, in the above example, the non-highlighted output remains for the field
F. When f has been output, the system reverts to the old format.
... AS CHECKBOX (output as checkbox)
Outputs the field f as a checkbox. The contents of the
first character of f is interpreted as the "status":
' ' = not selected
'X' = selected
The user can change this as required.
To prevent the user changing the contents of the checkbox, you can use the addition
... INPUT OFF. The checkbox is then nothing more than a status
display and can only be changed by programming.
In technical terms, a checkbox behaves exactly like
an input field with a length of 1 (FORMAT INPUT).
DATA: MARKFIELD(1) TYPE C VALUE 'X'.
...
WRITE MARKFIELD AS CHECKBOX.
"checkbox selected
MARKFIELD = SPACE.
WRITE MARKFIELD AS CHECKBOX. "deselected
WRITE MARKFIELD AS CHECKBOX INPUT OFF. "deselected, protected
List Creation
... AS SYMBOL (output as symbol)
You can output certain characters as symbols using the addition ...
AS SYMBOL. You should only address these characters with their system-defined names. The
include <SYMBOL> (or the more comprehensive include
<LIST>) contains the relevant identifiers as constants,
e.g. SYM_PHONE, SYM_CIRCLE. (List of symbols, Proposals for use).
INCLUDE
WRITE: / SYM_RIGHT_HAND AS SYMBOL, " output as symbol
'Tip, Note',
SYM_LEFT_HAND AS SYMBOL. " output as symbol
An output length of one character is enough for most symbols, but some (e.g.
SYM_FAX) are twice as long.
You can determine the length
of a symbol with DESCRIBE FIELD SYM_... OUTPUT-LENGTH ...
List Creation
... AS ICON (output as icon)
You can output certain characters as icons using the addition ...AS
ICON. You should only address these characters with their system-defined names. The include
<ICON> (or the more comprehensive include <LIST>)
contains the relevant identifiers as constants, e.g. ICON_OKAY (see List of icons).
INCLUDE
WRITE: / ICON_OKAY AS ICON, "output as icon
'Text line'.
Although an output length of 2 characters is enough for most icons, some (e.g. the traffic light icons
ICON_RED_LIGHT, ...) have a greater output length.
You
can determine the length of an icon with
DESCRIBE FIELD ICON_... output length ....
You cannot print out all list icons. The printable icons are flagged as such in the 'list of icons' mentioned above.
List Creation
... AS LINE (output as line)
On list output, automatically links certain characters together to form continuous lines or boxes, if there is no space between them:
Exactly how each line segment is output (e.g. whether as straight line, corner, T-piece or cross) depends on the adjoining characters.
A good rule of thumb sipulates that if the cell adjacent to a line character also contains a line character,
the missing piece required to form a connection is added. If an adjacent cell does not also contain
a line character, the line character is truncated on that side. Line characters standing on their own remain unchanged.
This technique is sufficient to cope with most cases (e.g. tables, boxes, simple hierarchies). However,
no matter how carefully you use some empty characters and lines, it is not possible to stop adjacent
line characters being joined in an inappropriate way (e.g. very compact hierarchy diagrams,
or densely boxes). The solution here is to output the required line segment explicitly using the addition ... AS LINE.
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.
Lines cannot have any other display attributes. If attributes such as color (
COLOR), reverse video (INVERSE)
or intensified (INTENSIFIED) are set, these are ignored
on output. If the ready for input attribute (INPUT) is set, the actual characters (minus sign, vertical line) are displayed.
Output two nested corner segments:
INCLUDE
ULINE /1(50).
WRITE: / SY-VLINE NO-GAP, LINE_TOP_LEFT_CORNER AS LINE.
ULINE 3(48).
WRITE: / SY-VLINE NO-GAP, SY-VLINE NO-GAP.
List Creation
General notes on outputting boxes to lists
When you output a list, this is sometimes combined with vertical and horizontal lines to form closed boxes:
... QUICKINFO g
The field f is displayed with the tool tip g: Whenever the mouse pointer is positioned on the display area of f, the contents of g are displayed as an explanatory text on the list (in a small, differently-colored box).
The tool tip can be up to 40 characters long.
g must be a non-numeric field (data type C, N, D, or T).
Tool tips are unsuitable for lines, input fields, or checkboxes. Their suitability is also limited for icons that are normally displayed in longer fields (the icon assignment may be inexact).
If two output fields overlap (for example, when one field is placed over another with the POSITION ... statement, the 'bottom' field may not have a tool tip.
The output length of
f must be greater than zero (f must actually
be placed on the list) if you want to use the ... QUICKINFO addition.
INCLUDE
DATA: INFO(20) VALUE 'Information'.
WRITE: / SY-UNAME QUICKINFO 'User name'.
WRITE: / ICON_INFORMATION AS ICON QUICKINFO info
HOTSPOT COLOR COL_POSITIVE.
Creating Lists