WRITE

WRITE - Output to a list


1. ... AT pl (position and length specification, before the field)
2. ... option (formatting option)
3. ... fmt (output format by field)
4. ... AS CHECKBOX (output as checkbox)
5. ... AS SYMBOL (output as symbol)
6. ... AS ICON (output as icon)
7. ... AS LINE (output as line)

Effect

Outputs the field f in the correct format for its type to the current list. The field f can be:

Examples

TABLES SPFLI. 
DATA N TYPE I VALUE 123. 
 
... 
WRITE N. 
WRITE SPFLI-FLTIME. 
 
FIELD-SYMBOLS <CF>. 
ASSIGN 'NEW YORK' TO <CF>. 
WRITE <CF>. 
 
WRITE: '---->', SPFLI-DISTANCE. 
 
WRITE: TEXT-001, SPFLI-ARRTIME.

or

WRITE: 'Time:'(001), SPFLI-ARRTIME.

Text symbols can be addressed in two different ways (TEXT-001 or 'Time:'(001)).

Notes

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.

Each field occupies a number of characters in the list. If this number is not explicitly defined (see addition 1), the system uses a type-specific standard length or the output length specified in the ABAP/4 Dictionary.

Type-specific output: (len = field length)

Type Standard output length Output
C len
left-justified
D 8 left-justified
F 22 right-justified
I 11 right-justified
N len left-justified
P 2*len or 2*len+1 right-justified
T 6 left-justified
X 2*len left-justified

Numeric fields (types P, I and F) are always output right-justified, but all other types are left-justified; if required, blanks are used for padding. With numeric fields, leading zeros are replaced by blanks. If there is enough space, types P and I have thousands separators. To accommodate the decimal point, the output length of type P fields is 1 byte longer.

System fields that are useful when generating lists are documented in System Fields for Lists.

Addition 1

WRITE AT f (position and length specification before the field)

Effect

You can use the position and length specification f to define the precise output position and length of a field. The specification consists of:

/ New line
p Output position (1-3 character number or variable)
(l) Output length (1-3 character number or variable)

Combinations are possible.

Examples

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

The position and length specification must appear before the field.

Effect

You can modify the output of the field f by using one of the special formatting options.

Effect

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.

Example

DATA F. 
 
FORMAT INTENSIFIED OFF INPUT. 
WRITE F INPUT OFF INVERSE COLOR 3.

Note

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.


When you output a list, this is sometimes combined with vertical and horizontal lines to form closed boxes: