AS ABAP Release 758, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Programming Language → SAP GUI User Dialogs → Classic Lists → Lists - Create →
WRITE
Syntax
WRITE {[AT] [/][pos][(len|*|**)]} dobj
[UNDER other_dobj]
[NO-GAP]
[int_format_options]
[ext_format_options]
[list_elements]
[QUICKINFO info].
1. ... [AT] [/][pos][(len|*|**)]
2. ... UNDER other_dobj
3. ... NO-GAP
4. ... QUICKINFO info
Effect
This statement formats the content of the data object dobj and writes it to the current page of the current list. This is either a screen list in the list buffer or a spool list. dobj is a general expression position with the restriction that no arithmetic expressions and no bit expressions can be specified directly.
For dobj, those data types are allowed that are grouped under the generic type simple:
Formatting the Output
The output is formatted
ext_format_options allows output to be formatted and the additions list_elements allow specific list elements to be displayed. By default, adjacent characters - and | in a list are joined to form continuous lines.
Output Position
The output position is either determined by the list cursor or can be specified using pos after AT or using UNDER. The list cursor itself can be adjusted using NO-GAP. At the start of every output, the output position in the list buffer is the same as the output position in the list representation. The positions of individual characters within an output field can differ between the list representation and the list buffer. In both cases, however, the output length is the same.
Output Length
The output length is determined either by the data type of dobj or can be specified after AT using len|*|**. len specifies an absolute length and * or ** are used to prevent unwanted truncations.
Page Break
If the last line of the current page is reached and a subsequent line is output, a new page is generated. The maximum number of lines is determined by the addition LINE-COUNT of the program-initiating statement or the statement NEW-PAGE. For the basic list, the event END-OF-PAGE is raised when the area reserved for the page footer is reached, and a new page is then created.
Line Break
Once the list cursor has been positioned with a previous output statement, if the output length is greater than the area available in the current line of the list buffer, the output goes to the next line. If this line is also not sufficient for a complete output, the output length is truncated accordingly, and the output is displayed in this line.
If the list cursor is positioned using by specifying pos or a statement BACK, NEW-LINE, NEW-PAGE, POSITION or SKIP and not with a previous output statement, the output is always displayed in the current line, and the output length is truncated, if necessary.
List Cursor
After the output is displayed, the list cursor is positioned by default in the second place after the output; the sy-colno and sy-linno system fields are set accordingly.
Field Help and Input Help
If the data object dobj is declared with reference to a data type from the ABAP Dictionary, the field and input help defined here are available in the list displayed on the window.
Hints
Example
WRITE output for data objects, function calls, string expressions and method calls.
DATA text TYPE string VALUE 'Hello classical list'.
WRITE / text.
WRITE / |{ text WIDTH = 40 ALIGN = RIGHT }|.
WRITE / to_upper( text ).
WRITE / |{ 6 * 7 }|.
WRITE / `4` && `2`.
WRITE / cl_abap_conv_codepage=>create_out( codepage = `UTF-8`
)->convert( text ).
... [AT] [/][pos][(len|*|**)]
Effect
The output position and length for the current statement WRITE can be defined after AT. The output position of existing outputs in the list buffer is overwritten with the output length of the new output. Once an existing output has been overwritten, the list cursor is placed at the next position and not the position after next.
The components of the specified position and length /,pos and len or * or ** must be specified with no blanks and in the given order. If position and length are only specified as numeric literals, the addition AT can be omitted.
| Data Type | * | ** |
| c | Number of columns needed in the list to display the entire content. Trailing blanks are ignored. This length can be greater than the implicit length. | Doubled length of the data object. |
| string | implicit length | Doubled length of contained characters. |
| n, x, xstring, utclong | Implicit length | implicit length |
| d | 10 | 10 |
| t | 8 for 24-hour format, 11 for 12-hour format | 8 without using the addition ENVIRONMENT TIME FORMAT, 11 using this addition |
| (b, s), f, i, int8, p | Length required to output the current value including thousands separators. The value used here is the value after the application of the possible additions CURRENCY, DECIMALS, NO-SIGN, ROUND, or UNIT. | Length required to output the maximum possible values, including signs and thousands separators. The value used here is the value after the application of the possible additions CURRENCY, DECIMALS, NO-SIGN, ROUND or UNIT. |
| decfloat16, decfloat34 | The same as for ** applies here. However, leading and trailing blanks are removed. | 24 or 26. These are the predefined output lengths that can also include thousands separators. If the values are too large, exceptions may be raised if the format O_SIGN_AS_POSTFIX from class CL_ABAP_FORMAT is specified after STYLE. |
If a conversion exit
is executed in relation to a data type in the ABAP Dictionary, this conversion exit is performed for
the relevant specified length when len is specified, and if
* or ** is specified, the conversion
exit is performed for the output length specified in the ABAP Dictionary. If
* or ** is specified, the output
length is then determined according to the rules explained above from the conversion exit. The specification
of * or ** when using formatting templates
(USING EDIT MASK, DD/MM/YYYY ...), follows special
rules. *
or ** cannot be specified together with the option TIME ZONE.
Hints
Example
Displays a text field text at different positions, with different output lengths.
DATA: text TYPE string VALUE '0123456789ABCDEF',
col TYPE i VALUE 25,
len TYPE i VALUE 5.
WRITE text.
WRITE /5(10) text.
WRITE AT col(len) text.
... UNDER other_dobj
Effect
The output is made in the current line at the position where the data object other_dobj was the output of a previous WRITE statement. The data object other_dobj must be written exactly as in the corresponding WRITE statement, including all possible specified offset/lengths and so on. If the data object other_dobj was not specified before, the addition is ignored. If it was specified more than once, the horizontal output position of the last WRITE statement is used.
The addition UNDER cannot be used together with a position pos specified after AT. For other_dobj, a
boxed component or component of a boxed component cannot be specified.
Hints
Example
Tabular output of flight connections.
DATA: carrid TYPE spfli-carrid,
connid TYPE spfli-connid.
WRITE: 10 'Carrier', 40 'Connection'.
ULINE.
SELECT carrid, connid
FROM spfli
INTO (@carrid, @connid).
WRITE: / carrid UNDER 'Carrier',
connid UNDER 'Connection'.
ENDSELECT.
... NO-GAP
Effect
The list cursor is positioned directly after the output and not in the place after the next place in the list buffer.
Example
The output of the two WRITE statements is NoGap.
WRITE: 'No' NO-GAP, 'Gap'.
... QUICKINFO info
Effect
A tooltip is assigned to the output. If the mouse cursor is placed on the output area of dobj, the content of info appears in a colored rectangle. info expects a character-like data object with length 80. Character strings that exceed this length are truncated after position 80.
The addition QUICKINFO is ignored for line elements and for fields that are ready for input. Only for checkboxes, the addition QUICKINFO is not ignored in SAP GUI for Windows if the profile parameter dynp/enhanced_system_feedback has the value TRUE. If a list output is overwritten by another output, no tooltip for the overwritten field appears at or after the position where overwriting starts.
Hint
The character @ is represented internally in the tooltip text by
@@ and it occupies two places rather than just one. This means that for every @ character, there is one less character available to display it.
Example
Additional information on the output of date and time.
WRITE: (10) sy-datum QUICKINFO 'Date of list creation',
(8) sy-uzeit QUICKINFO 'Time of list creation'.
See WRITE - TO