Programming

What Is ALV? An Overview of ABAP List Viewer/SAP List Viewer

The ABAP List Viewer (ALV) is a set of application programming interfaces (APIs; function modules or classes) for displaying data in a tabular or hierarchical format and built-in options for visual presentation and event processing.

 

ALV is originally short for ABAP List Viewer, but the current term found in SAP documentation is SAP List Viewer. This is of little importance, though: in everyday practice, it’s simply referred to as ALV, not by any longer name.

 

To users, ALV offers a friendly interface with a toolbar that allows each user to adjust the presented layout to their preferences and sort or filter data easily. Many standard SAP reports use ALV and it has become a popular tool when building custom ABAP reports due to its flexibility, ease of implementation, and variety of features.

 

 

ABAP List

The first tool for data output in tabular format was ABAP List (see figure below). Such output was generated by using the WRITE command to display one line of data on the screen. To present the data in a grid format, the fields needed to be placed at specific, static positions on the screen while processing data in a loop or a cycle.

 

ABAP List Output Example

 

This type of presentation, traditional in mainframe-based systems for the last century, was inconvenient for both developers and users. Developers had to write all the code manually to output each field, as well as the column headers and totals or subtotals. And users were offered only a rigid report structure that they couldn’t modify without requesting a change in the program. Making changes in such reports was also inconvenient and time-consuming.

 

ALV List

The first implementation of the ALV framework was the Classic SAP List Viewer, usually referred to as ALV List. As you can see in the next figure below, this was a major improvement over the plain ABAP List functionality: the columns are nicely aligned and the toolbar offers additional functionality, such as sorting, filtering, and subtotals. More importantly, users could choose which columns they wanted to view and in which order. Their preferences could be saved in a layout to be applied next time they ran the report.

 

For developers, ALV offered a unified set of tools for data presentation, with no more calculating the screen position of each column and writing all the code manually. When using the ALV framework, developers only needed to be concerned with preparing business data; the ALV framework took care of the presentation.

 

Classic SAP List Viewer supported single-level lists, like the one shown below, and multilevel or sequential lists.

 

ALV List Example

 

ALV Grid

The next step in the ALV evolution was ALV Grid: an Excel-like tabular format that is used to this day, although the specific APIs have evolved further. The first implementations of ALV Grid used SAP function modules with names starting with REUSE_ALV. The below figure shows an example of such a report in the BALVSD02_GRID SAP demo program.

 

ALV Grid Example Using Function Module

 

First Object-Oriented ALV Framework

The next iteration of the ALV framework was implemented using classes with names starting with CL_GUI_ALV. This aligned with the strategic introduction of object-oriented ABAP programming in SAP ERP version 4.6C. Visually the class-based implementation produced results very similar to the function module, but one notable difference was that it allowed an ALV object to be bound to a custom container on a screen. This made it possible to present not just one full-screen report but multiple ALV containers on the same screen.

 

SALV Framework

The current implementation of the ALV framework is called SALV and it’s been available at least since SAP NetWeaver 7.0. This framework is provided by classes with names starting with CL_SALV and supports the ALV table (first figure below), ALV tree (second figure), and hierarchical-sequential list (third figure) formats.

 

Grid versus Table: In previous ALV implementations, the Excel-like presentation format was called a grid, but in the SALV framework the same format is called a table. These are synonymous and you might hear both used interchangeably by developers, regardless of which specific framework they refer to.

 

ALV Table Example Using SALV Framework9

ALV Tree Example Using SALV Framework

 

Hierarchical-Sequential List Example Using SALV Framework

 

Although the previous ALV framework was already object-oriented, SALV offers a more modern implementation, using ABAP features and syntax that were not available in older versions.

 

ALV with IDA

A more recent variety of the SALV framework, called SAP List Viewer with Integrated Data Access (ALV with IDA), also takes advantage of in-memory database functionality.

 

ALV Demo Programs

Many demo programs have been made available by SAP to illustrate the possibilities of different ALV framework implementations. This table shows the demo program locations for each variety:

 

1880_09_table_001

 

Missing Data in ALV Demo Programs: Some of the ALV demo programs use special tables instead of the SAP flight training model. If you find that a demo program doesn’t show any data, execute Report BCALV_GENERATE_ALV_T_T2 to fill in the ALV demo tables.

 

Conclusion

You’ve now learned about the ALV technology and various frameworks that exist for it in SAP ERP systems. We’ve discussed the function-based and old class-based ALV frameworks, as well as modern implementations called SALV and ALV with IDA.

 

Editor’s note: This post has been adapted from a section of the book ABAP: An Introduction by Brian O’Neill and Jelena Perfiljeva.

Recommendation

ABAP: An Introduction
ABAP: An Introduction

Step into ABAP with this beginner's guide. First understand ABAP syntax and find out how to add data and logic to your applications. Then delve into backend programming: learn to work with the ABAP data dictionary, create database objects, and process and store data. Round out your skill set by practicing error handling, modularization, string manipulation, and more. With guided examples, step-by-step instructions, and detailed code you'll become an ABAP developer in no time!

Learn More
SAP PRESS
by SAP PRESS

SAP PRESS is the world's leading SAP publisher, with books on ABAP, SAP S/4HANA, SAP CX, intelligent technologies, SAP Business Technology Platform, and more!

Comments