Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Classic Lists →  Create lists 

WRITE

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


WRITE {[AT] [/][pos][(len||*)]} dobj 
      [UNDER other_dobj]
      [NO-GAP]
      [int_format_options]
      [ext_format_options]
      [list_elements]
      [QUICKINFO info].

Extras

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 in the list buffer. This is either a screen list in the list buffer or a print list. All flat data types and the data types string and xstring are allowed for dobj; structures are treated as a data object of type c and must be character-like in Unicode systems. In a Unicode system, only the data types grouped together under the simple generic type can be used. The data object dobj can be specified by a field symbol or a dereferenced data eference.

Formatting the output

The output is formatted according to

ext_format_options allows you to further format the formatted output, and the additions list_elements allow specific list elements to be displayed. By default, adjacent characters "-" and "|" in a list are joined together to form continuous lines.

Output position

The output position is either determined by the list cursor, or specified using pos after AT or by 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. In Unicode systems, 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 by the data type of dobj or it can be specified with len|| after AT. len specifies an absolute length, whereas or ** ensures that characters in Unicode systems are not truncated by mistake.

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 introductory statement or the statement NEW-PAGE. For the basics list, the END-OF-PAGE event is triggered when the area reserved for the page footer is reached, and a new page is subsequently generated.

Line break

Once the list cursor has been positioned with a previous output statement, if the output length is larger 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 shortened accordingly and the output is displayed in this line.

If the list cursor is positioned using the pos specification or a statement BACK, NEW-LINE, NEW-PAGE, POSITION or SKIP and not with a previous output statement, then the output is always displayed in the current line, and the output length is shortened, if necessary.

List Cursor

After the output is displayed, the list cursor is positioned by default in the second position after the output; the sy-colno and sy-linno system fields are set accordingly.

Field 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 screen.


Notes

  • In the default setting, the system does not place a new line that contains only blank characters in a list. A blank line is only outputed if the list cursor is directly positioned in an existing line, in other words, not using a line break. You can change this setting with the statement SET BLANK LINES ON.
  • Obsolete calculations used in connection with WRITE are still possible outside of classes.

Addition 1

... [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 position and length specification /,pos and len or or * must be listed with no spaces and in the specified sequence. If position and length are not specified at all or are declared as numeric literals, the addition AT can be omitted.

  • With /, the output is displayed in the next line after the current line. If no position pos is specified, the output is written from the first column onward. The specification of / has no effect immediately after positioning the list cursor in a list line (that is not the result of a previous output statement). This is the case during initial writing to a list page, and after explicit positioning with the statements SKIP, NEW-LINE, NEW-PAGE and BACK.
  • The output position is determined by specifying pos. pos expects a data object of type i that contains a value within the current list width. If the value in pos is less than 1, it is ignored. If it is greater than the current list width, there is no output.
  • The output length is determined by specifying len, * or ** in brackets. Using len, an absolute value can be specified. len expects a data object of type i which contains a value larger than zero and which is within the current list width. In Unicode systems, the number of characters displayed in the list can be different to the number of characters stored in the list buffer, if len is specified. By specifying * or **, the output length depends on the data type of the data object dobj, as shown in the following table.
Data Type * **
c Number of columns needed in the list to display the entire content; closing spaces are not taken into account. In Unicode systems, this length can be greater than theimplicit length. Doubled Length of Data Object
string implicit length Doubled length of contained characters.
n, x, xtring 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, p Length required to output the current value, including thousand separators. The value used hereis 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 thousand 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, opening and closing spaces are removed. 24 or 26. These are the predefined output lengths that can also include thousand separators. Ifthe values are too large, exceptions can occur if one of these formats - O_SIGN_AS_POSTFIX, O_MONETARY,O_EXTENDED_MONETARY - is defined under STYLE.

When a conversion routine is executed with reference to a data type in the ABAP Dictionary, if len is specified, the routine is performed for the relevant specified length, and if or is specified, the routine is performed for the output length specified in the ABAP Dictionary. If or is specified, the output length is then determined from the conversion routine result, using the rules explained above. When * or is specified, when using formatting templates (USING EDIT MASK, DD/MM/YYYY ...), special rules apply.


Notes

  • The specification of the output length len after AT should always be preferred over the use of a length specification for data object dobj (partial field access). In contrast to partial field access, the specification of the output length is not restricted to byte-type and character-type data objects. Furthermore, the assignment of the list output to the data object is lost during a partial field access, which means that it can no longer be addressed in the list.
  • The specification of * or ** for the output length ensures that, regardless of data type, all characters from dobj are displayed, even when more columns are needed in the list than positions in the list buffer. With *, the minimum possible length is used, and with **, the maximum possible length is used.
  • When an output position is specified within an existing output, you should ensure that the position always refers to the characters stored in the list buffer. If characters that require more than one column in the list are displayed in a Unicode system, the displayed output position can differ from the specified output position. In addition, the displayed content of a partially overwritten output can be shifted, depending on the characters that overwrote the output.

Example

This example outputs 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. 

Addition 2

... UNDER other_dobj

Effect

Output starts in the current line at the position, where the data object other_dobj has been output in a previous WRITE statement. The data object other_dobj must be written exactly as in the corresponding WRITE statement, including all possible offset/length specifications and so on. If the data object other_dobj has not been specified before, the addition is ignored. If it has been specified several times, 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.


Notes

  • Vertical positioning must be carried out by the user. If the list cursor is positioned underneath the output of other_dobj, the output also appears underneath. If the list cursor is positioned in the same line in which other_dobj is output, this output is overwritten. If the list cursor is positioned above the output of other_dobj, then the output also appears above.
  • The data object other_dobj should be defined globally in the current program. Using local data objects in procedures may lead to unwanted results, for example, if the components of the same structures are used in different procedures.
  • The data object other_dobj can also be specified as a field symbol or as a dereferenced data reference. In this case, the field symbol or data reference must not point to a row of an internal table.

Example

Table-type 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. 

Addition 3

... NO-GAP

Effect

The list cursor is positioned directly after the output (and not at the position after the next position in the list buffer).


Example

The output of the two WRITE statements is "NoGap".

WRITE: 'No' NO-GAP, 'Gap'. 

Addition 4

... QUICKINFO info

Effect

A quick info 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. For info, a character-type data object with length 40 is expected.

The addition QUICKINFO has no effect on input-ready fields and line elements. If a list output is overwritten by another output, then no Quickinfo for the overwritten field appears at or after the position where overwriting starts.


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'. 

Exceptions

See WRITE - TO

Continue

WRITE - Output Length

WRITE - int_format_options

WRITE - ext_format_options

WRITE - Lines

WRITE - list_elements

WRITE /.