Classic Lists and Interactive Reports
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
When an old ABAP report finishes, it shows its result as a list: plain lines of text on a screen, written one statement
at a time. If the user double-clicks a line, the report can answer with a second list that explains that line, and a
double-click on a line of the second list can open a third one. This is called drill-down, and a report that does it is
called an interactive report. A newcomer meets such reports in almost every system that has been running for a few years,
and a developer who maintains them has to know how the list is built, where the program remembers what each line
stands for, and what happens when the user clicks. After reading this page you can write a simple list, add a page
header, remember a value for each line with HIDE, react to a double-click with AT LINE-SELECTION, react to your
own buttons with AT USER-COMMAND, and change a line that is already displayed. The page is written against Standard
ABAP release 8.16. Everything here is classic ABAP, in S/4HANA on premise and Private Edition and in older systems alike.
Classic lists are not part of ABAP for Cloud Development (release 9.20, 2608), and the Keyword Documentation no longer
recommends them for production programs: use the SAP List Viewer (page ALV) or a Fiori elements app instead.
Before you read
-
Classic Reports and Event Blocks: the order in which the runtime calls the event blocks of a report, including the list events that this page works out in detail.
-
Program Types and Structure: what an executable program is and what a processing block is.
-
Data Types and Data Objects:
DATAand the system fields such assy-subrcthat this page extends with the list fields.
Key terms
-
Classic list: the page-oriented text output that
WRITEcreates and that the user sees on a special list screen. -
List buffer: the memory area in which the program keeps the lists it has written, one after the other.
-
Basic list: the first list of a program, with list level 0; it is what the report writes before the user does anything.
-
Details list: a list written in answer to a user action on a displayed list, with a list level of 1 or more.
-
List level: the position of a list in the list buffer, held in the system field
sy-lsind. -
List cursor: the position at which the next output lands, given by the system fields
sy-linno(line) andsy-colno(column). -
Hide area: the part of a list level in which
HIDEstores values together with the number of the current line. -
List event: an event raised while a list is built or after the user acts on a displayed list, for example
TOP-OF-PAGEorAT LINE-SELECTION. -
GUI status: the menu bar, toolbar and function keys of a screen or list, which decide which function codes the user can trigger.
-
Function code: the short name that a menu entry, button or function key sends to the program, available afterwards in
sy-ucomm.
What a classic list is
A classic list is not a table on a screen. It is text, written by ABAP statements into a memory area called the list buffer and then shown on a ready-made screen that belongs to the system (the list processor), not to your program. The Keyword Documentation describes it like this: output is either written to the list buffer as a screen list and displayed on a list dynpro, or sent to the SAP spool system as a spool list, which is what a printed list is. Classic lists are the only way for an ABAP program to send data directly to the spool system.
The facts that matter for programming:
-
Lines and pages. A list is made of lines up to 1,023 characters wide, divided into pages. The line width is in
sy-linsz, the current page insy-pagnoand the position of the next output, the list cursor, insy-linnoandsy-colno. A page holds at most 60,000 lines. -
Several lists. One list buffer holds the basic list (level 0) and up to 20 details lists (levels 1 to 20), so 21 lists in all. The statements that write always write into the current list, whose level is
sy-lsind. -
A displayed list is closed. After the basic list has been shown, you can no longer write to it. You can still read and modify it, which is what
READ LINEandMODIFY LINEdo (below). -
Global data and events. The list statements work on global data and on events of the runtime framework. The Keyword Documentation gives this as the reason why classic lists fit badly with ABAP Objects and why presentation and application logic are hard to separate in them.
-
Not accessible. The look of a classic list is not standardised, so it is usually not accessible. The SAP List Viewer handles accessibility for you.
Writing a list
Four statements do most of the work of building a list. Each one acts on the list cursor, so the best way to read them is to ask where the cursor is afterwards.
| Statement | What it does |
|---|---|
|
Writes the content of a data object, a literal, a string template or a function result at the list cursor. Afterwards
the cursor stands in the second place after the output, so two outputs in one line have a blank column between them.
The addition |
|
The slash starts the output in the next line. Without it, the output continues in the current line. |
|
Writes at an exact position and length. Position and length are written without blanks and in this order, and an
existing output at that place is overwritten. The additions |
|
Draws a horizontal line along the whole line and puts the cursor at the start of the next line. With |
|
Moves the cursor down n lines (one without n). In most cases this works like n blank lines, but they have no content
that |
|
Completes the current page and starts a new one. |
A few rules save a lot of confusion. By default the system does not put a line into a list that contains only blank
characters: a WRITE / of empty text leaves no blank line, and a blank line appears only when the cursor is moved into
an existing line, for example with SKIP. Control characters such as line feeds or tabs inside a string are not
interpreted, they show as #. The first output of a field fixes its length in the list buffer, so give an output an
explicit length when it can grow (WRITE AT with len) instead of cutting a field with a substring.
The next report writes a small list of Expense claims. It uses only the statements that the local playground runs
(plain text lines, a string template and SKIP), so its output is real. A line per claim is built in a template, and
the summary line uses REDUCE to add up the amounts.
REPORT zlist_demo.
TYPES: BEGIN OF ty_claim,
claim_id TYPE c LENGTH 10,
status TYPE c LENGTH 1,
amount TYPE i,
END OF ty_claim.
TYPES ty_claims TYPE STANDARD TABLE OF ty_claim WITH EMPTY KEY.
CLASS lcl_list DEFINITION FINAL.
PUBLIC SECTION.
CLASS-METHODS write_basic_list IMPORTING claims TYPE ty_claims.
ENDCLASS.
CLASS lcl_list IMPLEMENTATION.
METHOD write_basic_list.
DATA(total) = REDUCE i( INIT sum = 0 FOR line IN claims NEXT sum = sum + line-amount ).
WRITE / 'Claims'.
SKIP.
LOOP AT claims INTO DATA(claim).
WRITE / |{ claim-claim_id } { claim-status } { claim-amount }|.
ENDLOOP.
SKIP.
WRITE / |{ lines( claims ) } claims, total { total }|.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
lcl_list=>write_basic_list( VALUE #( ( claim_id = 'C-1001' status = 'S' amount = 155 )
( claim_id = 'C-1002' status = 'A' amount = 80 )
( claim_id = 'C-1003' status = 'S' amount = 20 ) ) ).
Output in the local playground (run with open-abap, see the lab section below):
Claims C-1001 S 155 C-1002 A 80 C-1003 S 20 3 claims, total 255
Source: ABAP Keyword Documentation: WRITE and SKIP
Every line is one string, so the list looks the same in a real system. If you write the number itself instead of a
string (WRITE / claim-amount), a real system formats it with its own length and alignment, which the playground does
not reproduce. That is why the listing builds the lines in templates. All output happens in one method that is called
from START-OF-SELECTION, as the previous page recommends.
Formatting, headers and the report options
FORMAT sets colour and behaviour for all the output that follows, until another FORMAT changes it. The most useful
additions are:
-
COLORwith a number or a name fromCOL_HEADING(1) toCOL_GROUP(7), for exampleCOL_TOTAL(3, yellow) orCOL_NEGATIVE(6, red); -
INTENSIFIED,INVERSE,INPUT(the field can be edited on the list) andFRAMES; -
HOTSPOT, which turns the area into something that reacts to a single click as if it were a double-click; -
RESET, which sets all settings back, exceptFRAMES, which is switched on.
The same additions can be written after one WRITE to override FORMAT for that output only, as in
WRITE / 'Total' COLOR COL_TOTAL. The settings are set back automatically at the start of every reporting event and
list event. Blank lines created with SKIP are not formatted.
A list page can have a header and a footer. The standard page header is built from the text elements of the program and shows
on top of every page. The event TOP-OF-PAGE is raised just before the first line of a new page is written, and
whatever you write in it becomes part of that page’s header, below the standard one. The event block ignores
NEW-PAGE. With TOP-OF-PAGE DURING LINE-SELECTION the same applies to the details lists. The footer is written in
END-OF-PAGE, which is raised when the area reserved for the footer is reached. Page header and footer lines are
useful because they let the same program fit different page lengths when a list goes to the spool.
The options that shape the basic list are written after REPORT, for example LINE-SIZE for the width, LINE-COUNT
for the page length and NO STANDARD PAGE HEADING to leave out the standard header. NEW-PAGE accepts the same
width and length options for the pages that follow.
Source: ABAP Keyword Documentation: FORMAT, TOP-OF-PAGE, NEW-PAGE and REPORT
Interactive lists
A list becomes interactive when the program contains at least one event block for a user action on a displayed list. The Keyword Documentation lists three:
-
AT LINE-SELECTION: the user chooses the function codePICKwith the cursor on a list line. The standard list status links the key F2, and with it the double-click of the mouse, toPICK, and writing this block is enough to activate that link. A hotspot makes a single click work the same way. -
AT USER-COMMAND: the user chooses a function code that you defined, for example a button of your own. The function code is insy-ucommwhen the block starts. The codesPICKandPFnndo not raise it, codes that start with%are system functions, and codes such asBACK,PRIor the scrolling codes are handled by the list processor without calling your program. -
AT PFnn: marked obsolete. It reacts to the function codesPF01toPF24and the documentation says to useAT USER-COMMANDwith your own function codes instead.
A program can also raise a list event itself with SET USER-COMMAND, instead of waiting for the user.
Each time one of these events is raised and you have written its block, sy-lsind is increased by one, the block runs,
and whatever it writes goes to a new details list. When the block ends normally, that list is shown. If the block
writes nothing, the previous list level is displayed again. After each list event block the statement NEW-LINE runs
implicitly, as in every event block.
The function code BACK takes the user to the previous list and reduces sy-lsind by one. On the basic list it leaves
the list and ends the program run. Your program can also assign a value to sy-lsind inside a list event block. If the value is lower than
the level of the list you are writing and not below 0, the list you write replaces the list of that level and all
lists above it are deleted from the list buffer. This is how a "refresh" function is written: set sy-lsind to 0, write
the list again, and the user is back on a fresh basic list. Any other value is reset when the block ends.
System fields of a list event
The runtime fills a group of system fields after every list event and after READ LINE. The most important are:
| Field | Meaning |
|---|---|
|
List level of the current list (0 for the basic list, 1 to 20 for details lists). It can be set by the program, as above. |
|
List level of the displayed list, the one the user acted on. |
|
Absolute number of the selected line in the displayed list, counted from 1. |
|
Content of the selected line. |
|
Function code that raised the event. |
|
Number of the first displayed page of the displayed list. |
|
Name of the GUI status of the list that is displayed. |
|
While a list is built: line, column and page of the list cursor. |
Remembering a line: HIDE
After a double-click the program knows which line, by number (sy-lilli) and by text (sy-lisel), but a number or the
visible text is a poor key. The visible text may be shortened or reformatted, and the number changes when the list
changes. The statement HIDE solves this. Put right after the WRITE that creates a line, HIDE dobj stores the
content of the variable dobj, together with the number of that line, in the hide area of the current list level.
Nothing is displayed. Later, when the user acts on that line, the runtime puts the stored values back into the
variables, before your event block starts. The variable holds, for example, the claim number of the line that was
clicked, even though that line shows the claim number, the status and the amount.
The rules, from the Keyword Documentation:
-
The variable must be global and flat. Class attributes, local variables and field symbols are not allowed. A local variable or a table line stops the program with a runtime error such as
HIDE_NO_LOCALorHIDE_ILLEGAL_ITAB_SYMBOL. -
Hide a value in the statement that sets the cursor in the line, so right after the
WRITE. -
A field that is too long raises
HIDE_FIELD_TOO_LARGE, and the number ofHIDEstatements per line is limited. -
A line that never had a
HIDE(the title or a ruler) has nothing stored. The documentation promises values only for lines whereHIDEran, so an event block must not take for granted what the variable holds after a click on such a line. A simple habit solves this: test the variable at the start of the block and clear it at the end. -
HIDEalso works for empty lines created withSKIP.
Source: ABAP Keyword Documentation: HIDE
Example: drill down from a claim to its items
The report below shows each claim of the Expense claims example on one line. A double-click, or a single click because
the lines are a hotspot, opens a details list with the items of that claim. A function code MARK from the GUI status
LIST colours the line the user is on. All event blocks only call methods of the local class, as the page on event blocks recommends. The two tables are the ones of the other pages of this section: zexp_claim with the claim number,
status and amount, and zexp_item with the claim number, an item number, a category and an amount.
This listing requires an SAP system; not run here. The local playground has no Dictionary tables of this kind, no GUI
status, no HIDE and none of the list events (see the lab section below). The status LIST must exist in the Menu
Painter (transaction SE41) with the function code MARK on a button, and with the key F2 left on the function code
PICK.
REPORT zexp_claim_list.
DATA gv_claim_id TYPE zexp_claim-claim_id.
CLASS lcl_list DEFINITION FINAL.
PUBLIC SECTION.
CLASS-METHODS header.
CLASS-METHODS basic_list.
CLASS-METHODS item_list.
CLASS-METHODS mark_line.
ENDCLASS.
CLASS lcl_list IMPLEMENTATION.
METHOD header.
WRITE / 'Claim St Amount'.
ULINE.
ENDMETHOD.
METHOD basic_list.
SELECT claim_id, status, amount
FROM zexp_claim
ORDER BY claim_id
INTO TABLE @DATA(claims).
SET PF-STATUS 'LIST'.
FORMAT HOTSPOT ON.
LOOP AT claims INTO DATA(claim).
WRITE / |{ claim-claim_id WIDTH = 10 } { claim-status } { claim-amount }|.
gv_claim_id = claim-claim_id.
HIDE gv_claim_id.
ENDLOOP.
FORMAT HOTSPOT OFF.
ENDMETHOD.
METHOD item_list.
SELECT item_no, category, amount
FROM zexp_item
WHERE claim_id = @gv_claim_id
ORDER BY item_no
INTO TABLE @DATA(items).
WRITE / |Items of claim { gv_claim_id }|.
ULINE.
IF items IS INITIAL.
WRITE / 'This claim has no items.'.
ENDIF.
LOOP AT items INTO DATA(item).
WRITE / |{ item-item_no } { item-category } { item-amount }|.
ENDLOOP.
ENDMETHOD.
METHOD mark_line.
READ CURRENT LINE.
IF sy-subrc = 0 AND gv_claim_id IS NOT INITIAL.
MODIFY CURRENT LINE LINE FORMAT COLOR 5.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
lcl_list=>basic_list( ).
TOP-OF-PAGE.
lcl_list=>header( ).
AT LINE-SELECTION.
IF gv_claim_id IS NOT INITIAL.
lcl_list=>item_list( ).
CLEAR gv_claim_id.
ENDIF.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'MARK'.
lcl_list=>mark_line( ).
CLEAR gv_claim_id.
ENDCASE.
Source: HIDE, AT LINE-SELECTION, AT USER-COMMAND, READ LINE and MODIFY LINE
How the program behaves, step by step:
-
The basic list is written in
START-OF-SELECTION. Each claim line hides the claim number, andTOP-OF-PAGEputs the column titles on top. After the last event block of the program the list processor shows the list, because the basic list of an executable program is displayed automatically. -
On a double-click the runtime puts the claim number of that line into
gv_claim_idand raisesAT LINE-SELECTION.sy-lsindis now 1, soitem_listwrites into details list 1, which is displayed when the block ends. -
A double-click on a line of the details list raises
AT LINE-SELECTIONagain at level 2. Those lines have no hidden value, the variable has been cleared, the test fails, nothing is written and the previous list is shown again. Without the test and theCLEAR, the old claim number could trigger another list. -
The button
MARKraisesAT USER-COMMANDwithsy-ucommequal toMARK.READ CURRENT LINEreads the line the cursor was on and, as a side effect, restores the hidden value.MODIFY CURRENT LINEthen redraws that line with a new line colour. The Keyword Documentation’s own example ofMODIFY CURRENT LINEdoes the same inAT LINE-SELECTION: it changes the colours of a double-clicked line without writing anything else.
READ LINE and MODIFY LINE give access to lines of lists that already exist, any level and any page, with the
additions INDEX for the list level and OF PAGE or OF CURRENT PAGE. READ LINE puts the line into sy-lisel, sets
sy-subrc to 0 if the line exists and restores all values hidden for that line. With FIELD VALUE it also reads the
content of single output fields, for instance a checkbox written with AS CHECKBOX. MODIFY LINE writes a line back
from sy-lisel; the output length that the first WRITE fixed cannot be changed, and the documentation advises to
leave sy-lisel alone and change the line through the additions of the statement.
What the local playground can run
The playground of this section (the abap-lab with open-abap, @abaplint/transpiler-cli and @abaplint/runtime
2.14.30, open-abap-core commit a9acc41, checked on 2026-11-13) turns a report into JavaScript and prints what WRITE
produces on the console. It has no list buffer, no pages and no list screen, so only the writing half of this page runs.
Each statement below was tried in a one-line or three-line report.
| Statement | Result in the playground |
|---|---|
|
Works. Each |
|
Prints a line of 50 hyphens. A real system draws a line along the whole width of the list, so the length differs. |
|
Prints the values joined without the blank column of a real list. |
|
Position and length are ignored, and the slash in |
|
Accepted and ignored. Nothing changes in the output. |
|
Stop the program with the error "source is undefined". |
|
The program stops with the message "not supported" (for |
|
Accepted, but they do nothing: the blocks are not part of the generated code, so a report that has only these blocks prints just its basic list and ends with exit code 0. |
Because several of these do not fail at all, an interactive report that "runs" in the playground proves nothing about its interactive part. Treat the output of the playground as the text of the basic list and nothing more. The interactive behaviour needs an SAP system and SAP GUI.
Common mistakes
-
Keeping a key in a variable that is not global, or in a class attribute.
HIDEaccepts only global flat variables. A class attribute does not work, so classic list programs keep theirHIDEfields as global data and pass them to the methods. -
Calling
HIDEsomewhere other than right after theWRITE. The value is stored with the line of the list cursor. Put it in the statement that set the cursor in the line, or it can end up on a different line. -
Expecting the hidden variable to be empty after a click on a title line. Test it at the start of the event block and clear it at the end, as the example does.
-
Using
AT PFnnin new code.AT PFnnis obsolete. Give your own buttons your own function codes and useAT USER-COMMAND. -
Replacing the standard list status and forgetting the double-click. A status made in the Menu Painter has to keep F2 linked to
PICK. If F2 is linked to another function code, each double-click raises that code’s event, usuallyAT USER-COMMAND, and notAT LINE-SELECTION. -
Going past the 20 details lists. The list buffer keeps 20 details lists, so a program that opens a new one on every click needs a limit or a reset of
sy-lsind. The Keyword Documentation example ofAT LINE-SELECTIONstops at list 20 for this reason. -
Making a classic list the output of new work. The Keyword Documentation gives the rule "Use SAP List Viewer" and permits
WRITEonly for small helper programs that are not meant for live use, where it plays the role ofSystem.out.printlnin Java orprintfin C.
Where this fits today
Classic lists and interactive reports are the oldest user interface of ABAP, and a book written for older releases
presents them as the normal way to show results, with AT LINE-SELECTION as the standard drill-down. That advice is
outdated for new development: the Keyword Documentation now says not to use classic lists in production programs, and
for tabular output the SAP List Viewer (CL_SALV_TABLE, page ALV) gives the same functions with sorting, filters and
accessibility built in. For new applications on S/4HANA the successors are Fiori elements apps on a RAP business object,
where the list report and the object page replace the list and its details list. You still meet classic lists every day
in maintenance work, in background jobs that print to the spool, and in function modules that return a list. When you
change one, keep the event flow in mind, change as little as possible, and move new logic into a class with a unit test.
The page on dynpros and module pools shows the other classic way to build screens, and the page on selection screens
shows how a report asks its questions before it writes the list.
Summary
-
A classic list is text written by
WRITE,ULINEandSKIPinto the list buffer and shown on a list screen: the basic list is level 0, each user action can add a details list up to level 20, andsy-lsindgives the level. -
The list cursor decides where the next output lands.
WRITE /starts a new line,NO-GAPremoves the blank column, andNEW-PAGE,TOP-OF-PAGEandEND-OF-PAGEhandle pages, headers and footers. -
FORMATsets colour and behaviour for the output that follows, andHOTSPOTturns a single click into the same action as a double-click. -
An interactive report reacts in
AT LINE-SELECTION(function codePICK) andAT USER-COMMAND(your own function codes from a GUI status set withSET PF-STATUS).AT PFnnis obsolete. -
HIDEstores a global variable together with the line, and the runtime restores it before the event block runs. Test it, use it, then clear it. -
READ LINEandMODIFY LINEread and change lines of a list that is already displayed. -
The local playground runs only the writing statements. Everything interactive requires an SAP system, and new work should use ALV or Fiori elements instead of classic lists.