A WRITE statement writes the content of data objects to a list. When you write using a WRITE statement, the output is stored in the list buffer and is displayed from there when the list is accessed.
Each time a data object is output with WRITE, the system determines an output length either implicitly or explicitly; the implicit output length depends on the data type. The output length defines the following two attributes:
If the output length is shorter than the length of the data object, the system shortens its content according to certain rules when writing the data to the list buffer. Any values lost in numeric fields are indicated by a *.
When a list is displayed or printed, the contents stored in the list buffer are transferred to the list as follows:
For this reason, the horizontal position of the list cursor only has the same meaning as the output column in a list displayed or printed in non-Unicode systems. In Unicode systems, this is only guaranteed for the top and bottom output limits.
To avoid cutting off values unintentionally as far as possible, the rules for WRITE statements in Unicode programs have been modified and extended.
If the data object specified in WRITE is a
flat structure, this must only be character-type in Unicode programs.
This also applies for the statement WRITE TO, in which the target field must also be character-type.
In Unicode programs, WRITE statements without an explicitly specified output length for all data objects with the exception of text field literals and data objects of the type string behave in the same way as in non-Unicode programs. This means fewer characters may be displayed in the list than are stored in the list buffer.
In the case of text field literals and data objects of the type string, the system assumes that all characters are to be displayed. For this reason, the implicit output length is calculated according to the characters in the data object in such a way that it corresponds to the number of columns required in the list. If this output length is greater than the length of the data object, superfluous positions are filled with blanks when the data is written to the list buffer. When displaying the data in the list, the system removes these blanks, since the character representation fills the output length exactly.
If a numeric data object is specified as an explicit output length after the AT addition for a WRITE statement, the value of this number is used as the output length, both in Unicode and non-Unicode systems. In Unicode systems, the number of characters displayed in the list can differ from the number of characters stored in the list buffer. As of Release 6.20, you can specify the output length in the following way instead of using numeric data objects:
The behavior of the output lengths (*) and
(**) when using the addition USING EDIT MASK and the templates for date fields is described in
Internal Formatting Options.
The additions DISPLAY OFFSET and MEMORY OFFSET take account of the fact that data objects can occupy different lengths when displayed in a list and when stored temporarily in the list buffer.
In accordance with this fact, the addition DISPLAY OFFSET off positions the cursor in the column in the output area specified in off for the SET CURSOR { FIELD f | LINE l } statement. The addition MEMORY OFFSET off positions the cursor on the character in the output area that is located in the position (of the data object in f) in the list buffer specified in off.
In the same way, a GET CURSOR { FIELD f | LINE l
} statement used with the addition DISPLAY OFFSET
off places the cursor position in the output area in the data object
off. When you use the addition MEMORY OFFSET off,
the cursor position in the list buffer that is assigned to the character displayed is placed in the
data object off. The addition DISPLAY is the standard setting and can therefore be ignored.
Class CL_ABAP_LIST_UTILITIES
has been introduced to calculate output lengths, convert values from the list buffer, and define field
limits. The return values of the methods of this class can be used to program a correct column alignment in ABAP lists, even for output of Eastern Asian characters.
The objects in a list can be displayed in different output lengths by specifying the desired length
in the menu under System → List → Unicode Display. This is particularly advantageous for screen lists in
Unicode systems where the output is cut off as indicated by the characters > or <.
We recommend that you adhere to the following rules when programming lists, to ensure that they have the same appearance and functions both in Unicode and non-Unicode systems: