SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP Overview → ABAP and Unicode → Differences between Unicode and Non-Unicode Programs →Lists in Unicode Systems
Introduction
A WRITE statement writes the content of data objects to a list. When data is written with a WRITE statement, the output is stored in the list buffer and accessed from there for display when the list is called.
Each time a data object is produced by WRITE, the system defines 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 displaying or printing a list, the content stored in the list buffer is 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.
Rules for WRITE Statements
To avoid cutting off values unintentionally as far as possible, the rules for WRITE statements in Unicode programs have been modified and extended.
Operands in the WRITE Statement
If the data object specified in WRITE is a flat structure, this must be purely character-like in Unicode programs.
Note
This also applies for the statement WRITE TO, in which the target field must also be character-like.
WRITE Statements with Implicit Output Length
In Unicode programs, WRITE statements without an explicitly specified output length for all data objects except 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 using the characters contained in the data object so that it corresponds to the number of columns needed in the list. If this output length is greater than the length of the data object, surplus 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.
WRITE Statements with Explicit Output Length
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. 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 Formatting Options.
Additions for GET/SET CURSOR FIELD/LINE
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 DISPLAY addition is the default and can be left out.
Class for Formatting Lists
Class CL_ABAP_LIST_UTILITIES has been introduced to calculate output lengths, convert values from the list buffer, and define field limits. The return codes 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.
List Settings
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 <.
Recommendations
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: