Lists - OverviewOther versions: 7.31 | 7.40 | 7.54
Lists as Screens
By default, classic lists (or lists for short) are screens that contain text output defined using ABAP statements instead of screen elements in their display area. Lists are displayed as part of a special list dynpro, which is a component of the list processor system program.
Lists in ABAP Programs
An ABAP program can process multiple lists, which are stored in one or more list buffers. Each time a dynpro sequence is called, a new list buffer is opened and assigned to this dynpro sequence. A single list buffer can contain up to 21 lists: one basic list and 20 details lists. A list index is assigned to each list, and this index organizes the lists in the list buffer in hierarchical list levels. The first list of a list buffer is the basic list with list index 0. All other lists, whose list indexes are increased continuously starting at 1, are details lists.
The output statements of an ABAP program write to the current list, whose list index is determined by
sy-lsind system field. The current list after the call of a dynpro sequence is the basic list. As long as the basic list is not displayed, no other list levels can be created.
The basic list is displayed either implicitly during the processing of an executable program (see
SUBMIT) or explicitly using the
LEAVE TO LIST-PROCESSING statement. In both cases, the list processor
is called, which then sends the list to the list dynpro. Displaying this list closes it in the list buffer. It can no longer be written to, but it can be read or modified.
Every user action on a displayed list, which triggers a list event for which an event block is defined in the ABAP program, creates a new details list. The list index of this details list is always one more than the list index of the list on which the event was triggered. This index is contained in the sy-listi system field. The output statements of the event block write to the current details list. If the event block is finished normally, the details list is displayed automatically in the list dynpro.
User actions on displayed lists can cause a stack of up to 20 details lists to be created in the list buffer. The list with the highest list index
sy-lsind) is always the current list of the ABAP program, while the list with the list index one below the highest
sy-listi) is displayed on the screen. In certain list processing statements, the list index can be used to access all lists within the stack for reading or changing.
The details list stack in a list buffer can be reduced in two ways:
sy-lsindby 1. In the basic list, "BACK" causes the current dynpro sequence to be exited.
sy-lsind. If the value of
sy-lsindafter the event block is closed is less than the list index of the current list and greater than or equal to 0, then the current list replaces the list of this list level and all lists whose list index is greater than the value of
sy-lsindare deleted from the list buffer. Other values of
sy-lsindare reset to the index of the current list after the event block is closed.
Structure of a List
A list is made up of list rows with a fixed width of up to 1023 characters. The row width of the current
list is stored in the
sy-linsz system field. The number of rows of a list is limited only by the storage capacity of the system.
A list is divided into pages. Every list starts on page 1. The current page of the current list is stored
sy-pagno system field. The output position on the current page in
the list buffer is determined by the list cursor, which is provided in the system fields
sy-linno (row). A page can contain a maximum of 60000 rows.
The number of rows per page is stored for the current list in the
sy-linct system field. The value 0 represents the maximum number of rows per page.
On every page of a list, rows can be used for a page header and a page footer. The rows of the page header of the basic list are by default filled with a standard page header from the text elements of the ABAP program. The standard page header consists of a standard title and can contain column headings. The standard title is fixed so that it does not disappear when the page is scrolled vertically on the screen.
In the list event
the page header can be filled with additional rows. The page footer can only be filled only in the list
END-OF-PAGE. The entire
page header of the list displayed on top is fixed so that it does not move when the page is scrolled
vertically. The column headings of the standard page header and the rows filled in
TOP-OF-PAGE are moved when the page is scrolled horizontally.
The lists in the list buffer are screen lists. Their content is displayed in the list dynpro after an implicit call of the list processor in an
executable program or after an explicit call using
LEAVE TO LIST-PROCESSING.
When lists are created, there is also the option of excluding individual pages or all pages of one or
more lists from the screen display and to send them to the SAP spool system instead. This is done using
PRINT ON of
NEW-PAGE. All these pages together then form the spool list.
See also Spooling Lists.
Characters in lists
Any character supported by the current system code page can be displayed in a list. The prerequisite here is that a code page or a font is defined in the output medium (GUI, printer), into which the characters can be converted. Control characters for line breaks or tabs are ignored in strings and cannot be displayed. Non-displayable characters, such as control characters and non-convertible characters, appear as the # character in list output.
The program DEMO_CHARACTERS_IN_LISTS shows the current display of all characters that are assigned to the hexadecimal codes "0000" to "FFFF" in the current code page.
Lists and ABAP Objects
The list processing statements covered in this section are based on global data and events of the runtime environment and are no longer completely supported in ABAP Objects and when using ABAP Objects.
Classic lists are no longer intended to be used directly in production programs. The use of other suitable output media is recommended instead.
- For table list output, the classes of SAP List Viewer (ALV), such as CL_SALV_TABLE, should be used.
- For simple text output, the wrappers of the browser control, such as dynamic documents or wrappers of the textedit control should be used. "Dynpros, Text Output" shows an example of the latter.
- For simple console output, XML-based output streams can be used. An example of this is shown by the class CL_DEMO_OUTPUT_STREAM. The program DEMO_OUTPUT_STREAM shows potential uses of this class. The class CL_DEMO_OUTPUT, which is based on CL_DEMO_OUTPUT_STREAM, is used in programs from the ABAP Example Library.
Lists and Unicode
When a list is displayed or spooled, the contents stored in the list buffer are copied to the list, with the following differences between non-Unicode and Unicode systems:
- In Unicode systems, every character usually occupies one place in the
list buffer. On the list, however, a character can occupy more than one column (especially Eastern Asian
characters). However, since the list only contains the same number of columns as there are places in
the list buffer, this means the list can only display fewer characters than are saved in the list buffer. The list output is shortened accordingly (the page is displayed according to the
alignment) and is flagged
<). On a displayed list, the entire list content can be displayed by choosing System → List → Unicode Display.
- In non-Unicode systems, every character requires as much space in the list buffer as columns on the list. In single-byte systems, a character occupies one byte in the list buffer and one column in the list, while a character that occupies more than one byte in the list buffer in multi-byte systems also occupies the same number of columns in the list. For this reason, all the characters saved in the list buffer are displayed in the list in non-Unicode systems.
For these reasons, the horizontal position of the list cursor is equal to the output column of a displayed or spooled list only in non-Unicode systems. In Unicode systems, this is only guaranteed for the top and bottom output limits.
It is best to stick to the following rules when programming lists, to ensure that they have the same appearance and functions both in Unicode and non-Unicode systems:
- Specify an adequate output length
- Do not overwrite parts of a field
- Do not use the additions
WRITE TOif this statement is followed by list output with
- In customer-programmed horizontal scrolling with a
SCROLLstatement, only the upper or lower limit of data objects displayed should be specified, since the positions in the list buffer and in the list displayed are only certain to match for these field limits in Unicode systems.