Show TOC Entering content frame

Background documentation Formatting Lists Locate the document in its SAP Library structure

1.       Introduction

2.       Rules for the WRITEStatement

3.       Additions for GET/SET CURSOR FIELD/LINE

4.       Class for Formatting Lists

5.       List Settings

6.       Recommendations

 

1. Introduction

The WRITE statement writes the contents of data objects to a list. When writing with the WRITE statement, the output is stored in the list buffer and displayed from here when the list is called.  Whenever a data object is output using WRITE, an output length is specified implicitly or explicitly; the implicit output length depends on the data type. The output length defines:

·        The number of places or memory spaces available for characters in the list buffer

·        The number of columns or lines available in the actual list

If the output length is shorter than the length of the data object, its content is truncated according to specific rules when it is written to the list buffer; any value loss in the case of numeric fields is indicated by the * character. When displaying or printing a list, the contents stored in the list buffer are transferred to the list as follows:

·        In non-Unicode systems, every character requires the same amount of space (number of bytes) in the list buffer as it does columns in the list. In single-byte systems, one character occupies one byte in the list buffer and one column on the list, while a character that occupies several bytes in the list buffer in multi-byte systems also requires the same number of columns on the list. In non-Unicode systems, every character requires the same amount of space (number of bytes) in the list buffer as it does columns in the list.

·        In Unicode systems, a character generally occupies one position in the list buffer, but it can occupy more than one column in the list (this applies to East Asian characters in particular). However, since the same number of columns are available in the list as there are places in the list buffer, fewer characters can be displayed in the list than are stored in the list buffer. The list output is therefore truncated accordingly; the side depends on the alignment and one of the characters > or < is used. You can then display the entire contents of a truncated list by choosing System ® List ® Unicode Display.

For these reasons, the horizontal position of the list cursor is only gleichbedeutend with the output column of a displayed or printed list in non-Unicode systems. In Unicode systems, this is only guaranteed for the upper and lower output limits of the individual outputs.

 

2. Rules for the WRITE Statement

To avoid unintentional truncation as much as possible; the rules for the WRITE statement in Unicode programs have been adapted and extended.

WRITE Statement with Implicit Output Length

In Unicode programs, the WRITE statement behaves the same as in non-Unicode programs if you do not explicitly specify the output length for all data objects that can be output, with the exception of text field literals and data objects of the type string. As a result, it may happen that fewer character are 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, it is assumed that all characters are to be displayed.Therefore, the implicit output length is calculated, based on the characters contained in the data object, such that it matches the number of columns required in the list. If this output length is longer than the length of the data object, any excess positions are filled with blanks when writing to the list buffer. When the list is displayed, the blanks are truncated, since the character display fills the output length exactly.

WRITE Statement with Explicit Output Length

If, for the WRITEstatement, a numeric data object is specified after the ATaddition as the explicit output length, 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, the output length can be defined as follows, except when using numeric data objects:

·        WRITE AT (*) ...

-         In the case of data objects of the types c and string, the output length is set to the number of columns required to display the entire content on the list. Closing blanks for type c are ignored. For data objects of the type string, this is synonymous with the implicit length.

-         For data objects of the types dand t, the output length is set to 10 and 8.

-         In the case of data objects of the numeric types i, f, and p, the output length is set to the value required to display the current value including thousand separators; the value used is the one after any of the possible additions CURRENCY, DECIMALS, NO-SIGN, ROUND, or UNIT are used.

-         For data objects of the types n, x, and xstring, the implicit output length is used.

·        WRITE AT (**) ...

-         In the case of data objects of the type c, the output length is set to double the length of the data object and to double the number of contained characters in the case of data objects of the type string.

-         For data objects of the types dand t, the output length is set to 10 and 8.

-         In the case of data objects of the numeric types i, f, and p, the output length is set to the value required to display the maximum possible values of these types including prefixes and thousand separators; the value used is the one after any of the possible additions CURRENCY, DECIMALS, NO-SIGN, ROUND, or UNIT are used.

-         For data objects of the types n, x, and xstring, the implicit output length is used.

 

3. Additions for GET/SET CURSOR FIELD/LINE

The additions DISPLAY OFFSET and MEMORY OFFSET take into account that data objects can occupy different lengths when displayed in a list (DISPLAY) or stored in the list buffer (MEMORY). This is because Unicode codepages contain characters that only occupy one memory space but require two output spaces when displayed.

At the SET CURSOR { FIELD f | LINE l } statement, the DISPLAY OFFSET off addition positions the cursor accordingly, on the column of the output area specified in off. With the MEMORY OFFSET off addition, the cursor is placed on the character in the output area that is at the position specified in off (of the data object in f) in the list buffer.

Similarly, the GET CURSOR { FIELD f | LINE l } statement places the cursor into the data object off in the output area if the DISPLAY OFFSET off addition is used. If the MEMORY OFFSET off addition is used, the cursor position of the list buffer is placed in the data object off. The DISPLAY OFFSETaddition is the default and can therefore be omitted.

 

4. Class for Formatting Lists

The class CL_ABAP_LIST_UTILITIEShas been introduced for calculating output lengths, converting values from the list buffer, and defining field limits. With the return values of its methods, you can program correct column alignment with ABAP lists even if East Asian characters are displayed.

 

5. List Settings

The objects of a list can be displayed in different output lengths; to set the desired length, choose System ® List ® Unicode Display. This is particularly advantageous for screen lists in Unicode systems whose outputs were truncated (as indicated by the characters > or <).

 

6. Recommendations

To ensure that lists have the same appearance and functions both in Unicode and in non-Unicode systems, it is recommended that you observe the following rules when programming lists:

·        Specify a sufficient output length

·        Do not overwrite parts of fields

·        Do not use WRITETOwith RIGHT-JUSTIFIED or CENTERED and subsequent WRITE output

·        If you have programmed horizontal scrolling using the SCROLL statement, only the upper and lower limits of output data objects should be specified, since, in Unicode systems, the positions in the list buffer and on the displayed list will only match for these field limits.

 

Leaving content frame