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

Key terms

  • Classic list: the page-oriented text output that WRITE creates 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) and sy-colno (column).

  • Hide area: the part of a list level in which HIDE stores 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-PAGE or AT 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 in sy-pagno and the position of the next output, the list cursor, in sy-linno and sy-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 LINE and MODIFY LINE do (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

WRITE dobj

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 NO-GAP removes that blank column.

WRITE / dobj

The slash starts the output in the next line. Without it, the output continues in the current line.

WRITE AT /pos(len) dobj

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 * and ** instead of a length choose a length that is long enough for the value.

ULINE

Draws a horizontal line along the whole line and puts the cursor at the start of the next line. With AT pos(len) it draws a shorter line, which together with WRITE makes a frame.

SKIP n

Moves the cursor down n lines (one without n). In most cases this works like n blank lines, but they have no content that FORMAT could colour. SKIP TO LINE n jumps to line n of the current page.

NEW-PAGE

Completes the current page and starts a new one. sy-pagno goes up by one, TOP-OF-PAGE is raised before the first output on it, and with additions it also sets the page size or sends the following pages to the spool.

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

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:

  • COLOR with a number or a name from COL_HEADING (1) to COL_GROUP (7), for example COL_TOTAL (3, yellow) or COL_NEGATIVE (6, red);

  • INTENSIFIED, INVERSE, INPUT (the field can be edited on the list) and FRAMES;

  • 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, except FRAMES, 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.

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 code PICK with the cursor on a list line. The standard list status links the key F2, and with it the double-click of the mouse, to PICK, 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 in sy-ucomm when the block starts. The codes PICK and PFnn do not raise it, codes that start with % are system functions, and codes such as BACK, PRI or the scrolling codes are handled by the list processor without calling your program.

  • AT PFnn: marked obsolete. It reacts to the function codes PF01 to PF24 and the documentation says to use AT USER-COMMAND with 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.

sequenceDiagram actor U as User participant R as List processor participant P as Report P->>R: Basic list written into the list buffer, level 0 R->>U: Show the basic list U->>R: Double-click a line, function code PICK R->>P: AT LINE-SELECTION with sy-lsind 1 and sy-listi 0 P->>R: Details list written, level 1 R->>U: Show details list 1 U->>R: Choose Back R->>U: Show the basic list again, sy-lsind 0

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

sy-lsind

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.

sy-listi

List level of the displayed list, the one the user acted on.

sy-lilli

Absolute number of the selected line in the displayed list, counted from 1.

sy-lisel

Content of the selected line.

sy-ucomm

Function code that raised the event.

sy-cpage

Number of the first displayed page of the displayed list.

sy-pfkey

Name of the GUI status of the list that is displayed.

sy-linno, sy-colno, sy-pagno

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_LOCAL or HIDE_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 of HIDE statements 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 where HIDE ran, 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.

  • HIDE also works for empty lines created with SKIP.

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.

How the program behaves, step by step:

  1. The basic list is written in START-OF-SELECTION. Each claim line hides the claim number, and TOP-OF-PAGE puts 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.

  2. On a double-click the runtime puts the claim number of that line into gv_claim_id and raises AT LINE-SELECTION. sy-lsind is now 1, so item_list writes into details list 1, which is displayed when the block ends.

  3. A double-click on a line of the details list raises AT LINE-SELECTION again 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 the CLEAR, the old claim number could trigger another list.

  4. The button MARK raises AT USER-COMMAND with sy-ucomm equal to MARK. READ CURRENT LINE reads the line the cursor was on and, as a side effect, restores the hidden value. MODIFY CURRENT LINE then redraws that line with a new line colour. The Keyword Documentation’s own example of MODIFY CURRENT LINE does the same in AT 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

WRITE / text, string templates, SKIP

Works. Each WRITE / starts a new line, SKIP adds one blank line.

ULINE

Prints a line of 50 hyphens. A real system draws a line along the whole width of the list, so the length differs.

WRITE: / a, b in one statement

Prints the values joined without the blank column of a real list.

WRITE AT /10(8) text, positions such as 5 in WRITE: /5 text

Position and length are ignored, and the slash in WRITE AT /pos(len) does not start a new line.

FORMAT, COLOR, HOTSPOT

Accepted and ignored. Nothing changes in the output.

sy-uline, sy-vline, sy-lsind, sy-pagno in a WRITE

Stop the program with the error "source is undefined".

NEW-PAGE, SET PF-STATUS, SET USER-COMMAND, READ LINE, TOP-OF-PAGE, END-OF-PAGE

The program stops with the message "not supported" (for SET PF-STATUS and READ LINE "transpiler todo").

HIDE, AT LINE-SELECTION, AT USER-COMMAND

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. HIDE accepts only global flat variables. A class attribute does not work, so classic list programs keep their HIDE fields as global data and pass them to the methods.

  • Calling HIDE somewhere other than right after the WRITE. 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 PFnn in new code. AT PFnn is obsolete. Give your own buttons your own function codes and use AT 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, usually AT USER-COMMAND, and not AT 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 of AT LINE-SELECTION stops 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 WRITE only for small helper programs that are not meant for live use, where it plays the role of System.out.println in Java or printf in 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, ULINE and SKIP into 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, and sy-lsind gives the level.

  • The list cursor decides where the next output lands. WRITE / starts a new line, NO-GAP removes the blank column, and NEW-PAGE, TOP-OF-PAGE and END-OF-PAGE handle pages, headers and footers.

  • FORMAT sets colour and behaviour for the output that follows, and HOTSPOT turns a single click into the same action as a double-click.

  • An interactive report reacts in AT LINE-SELECTION (function code PICK) and AT USER-COMMAND (your own function codes from a GUI status set with SET PF-STATUS). AT PFnn is obsolete.

  • HIDE stores 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 LINE and MODIFY LINE read 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.