Show TOC

Background documentationPositioning WRITE Output on the List Locate this document in the navigation structure

 

You can position the output of a WRITE statement on the list by making a format specification before the field name as follows:

Syntax

WRITE AT [/][pos][(len)] f.

where

  • the slash '/' denotes a new line,

  • pos is a number or variable up to three digits long denoting the position on the screen,

  • len is a number or variable up to three digits long denoting the output length.

If the format specification contains only direct values (that is, no variables), you can omit the keyword AT.

Syntax Syntax

  1. WRITE 'Erste Zeile.'.
  2. WRITE 'Noch erste Zeile.'
  3. WRITE /'Zweite Zeile.'
  4. WRITE /13 'Dritte Zeile.'
End of the source code.

Syntax Syntax

This generates the following output on the screen:

  1. Erste Zeile. Noch erste Zeile. 
  2. Zweite Zeile.
  3.             Dritte Zeile.
End of the source code.

If you specify a certain position pos, the field is always placed in that position regardless of whether or not there is enough space available or whether other fields are overwritten.

Syntax Syntax

  1. DATA: len TYPE i VALUE 10,
  2.       pos TYPE i VALUE 11, 
  3.       text(10) TYPE c  VALUE '1234567890'
    
    
  4. WRITE 'Der Text ------------ erscheint im Text.'.   
  5. WRITE AT pos(len) text.   
End of the source code.

Syntax Syntax

This produces the following output:

  1. Der Text -1234567890- erscheint im Text.
End of the source code.

If the output length 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.

Syntax Syntax

  1. DATA: number   TYPE i VALUE  1234567890, 
  2.       text(10) TYPE c VALUE 'abcdefghij'. 
  3. WRITE: (5) number, /(5) text.   
End of the source code.

Syntax Syntax

This produces the following output:

  1. *7890
  2. abcde
End of the source code.

In the default setting, you cannot create empty lines with the WRITE statement. You can learn more about empty lines and how to change the default setting under Inserting Blank Lines in the section 'Creating Lists'.

Syntax Syntax

  1. WRITE:   'One',
  2.         / '   ',
  3.         / 'Two'.
End of the source code.

Syntax Syntax

This produces the following output:

  1. One
  2. Two
End of the source code.

The system suppresses lines that contain nothing but blanks.