Show TOC

Positioning WRITE Output on the ListLocate this document in the navigation structure

Use

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.

          
WRITE 'Erste Zeile.'.
          
WRITE 'Noch erste Zeile.'
          
WRITE /'Zweite Zeile.'
          
WRITE /13 'Dritte Zeile.'
            

This generates the following output on the screen:

          
Erste Zeile. Noch erste Zeile.
          
Zweite Zeile.
          
Dritte Zeile.
            

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.

          
DATA: len TYPE i VALUE 10,
          
pos TYPE i VALUE 11,
          
text(10) TYPE c VALUE '1234567890'
          
WRITE 'Der Text ------------ erscheint im Text.'.
          
WRITE AT pos(len) text.
            

This produces the following output:

          
Der Text -1234567890- erscheint im Text.
            

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.

          
DATA: number TYPE i VALUE 1234567890,
          
text(10) TYPE c VALUE 'abcdefghij'.
          
WRITE: (5) number, /(5) text.
            

This produces the following output:

          
*7890
          
abcde
            

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

          
WRITE: 'One',
          
/ ' ',
          
/ 'Two'.
            

This produces the following output:

          
One
          
Two
            

The system suppresses lines that contain nothing but blanks.