Professional Documents
Culture Documents
Overview
If it becomes necessary to write ABAP code to create your reports, then consider using the
ABAP List Viewer (ALV) to simplify your development. Available in the R/3 System since
Release 3.1, the ABAP List Viewer supports many of the standard R/3 reports. The ALV
provides additional program code you can quickly add to any custom report for any SAP
module.
Many reports developed for Release 4.0 (and later) utilize the ABAP List Viewer.
Additionally, many older standard R/3 reports (and reporting tools) have been modified to
include the ABAP List Viewer.
The ABAP List Viewer can be used with any application component or module in the R/3
System. We recommend that developers should adopt ABAP List Viewer as a design
principle in all report development activities that occur in your organization.
Note: At the time of press, limited technical support is available for the ABAP List
Viewer. However, we believe that support limitations should not prevent you from
taking advantage of the functionality offered by ALV.
The ALV is a set of function modules that are added to program code. Programs created
before Release 3.1 can be enhanced with the ALV by adding links to the function modules.
Developers can use the functionality of the ALV when creating new reports, thus saving
time which might otherwise have been spent on report enhancement. Using the ALV also
provides a uniform user-interface and list format for ABAP reports. This standardization
helps eliminate redundant functions.
The ABAP List Viewer enables both simple and sequential (hierarchical) report lists. Simple
lists contain a number of non-hierarchical, user-defined columns. Sequential lists contain
columns that consist of column headings and their subordinate rows.
Before taking advantage of the features of ALV, developers may want to consider the
benefits gained versus the “extra time” taken to include ALV in report development. The
following table shows estimates of time expenditures in report development. Note that an
estimated 50% of report developers’ time is consumed by building “fancy” features and
enhancing the look-and-feel of custom reports.
ABAP Report Development Activity Without ALV Percentage of Time Taken to Complete
SAP developed the ABAP List Viewer to help reduce the time and effort spent on some of
the report development activities. By using the ALV in the programming of custom reports,
you could reduce the development time by an estimated 40% (see table below).
ABAP Report Development Activity With ALV Percentage of Time Taken to Complete
Although, the use of ALV adds one more development activity (that is, preparation of the
field catalog), the development time spent on other activities is either eliminated or vastly
reduced.
When a report is written, the report list (output) depends almost entirely on how the
developer programmed the report.
Shown below is a sample report list where the programmer did not to use the ABAP List
Viewer. For illustration purposes, consider a report that was simply written (using the
WRITE command) to the screen. The output of a report created with just the WRITE
statement is shown below:
No column headings
A key point to note is that the function bar is blank. In addition, the data in the list is “dead”
which means that data listed cannot be used for any further data retrieval. It is essentially a
“data-dump.” Among other things, there are no headings for the columns. Any additional
functionality would have to be programmed. In short, the interface between the data you
see on the screen and the user’s eyes (the GUI) is limited and bland.
Report users routinely ask for additional features in their reports. Often they are looking for
the ability to:
< Sort
Hint: These
functions are < Resize rows
all available < Double-click on one information element to jump to another information element
in ALV
< Perform basic calculations
< Download “stylized” spreadsheets
< Display several colors
< Visually separate various pieces of information on the screen
However, for the most part, these features need to be programmed into the list as added
functionality to the output of the report. While some of these added functions are relatively
easy to program, the manner in which this added functionality works may vary greatly. For
example, one programmer may decide to enable a single-click as sufficient user input to
jump to a next level of information, while another programmer requires a double-click.
Similarly, one programmer may set the output of a field at 10 characters long, but another
programmer may program it as 20 characters.
When you insert the ALV code in your ABAP report program, the report list comes “alive.”
Compare the ALV-enabled list shown on page A-6 with the list shown on the previous page.
Although the data is the same, the program has been changed to incorporate the ALV
function modules.
With the ALV, the user is presented with a standard interface which, from the outset,
includes:
< Headers for the columns that appear on the list.
< Colors that correspond to indented key information
< Buttons that appear on the function bar (some of whose functions will be introduced in
the pages that follow)
As you review the additional functionality shown above, remember that without the ALV
each function would have to be programmed into the report.
Note: This appendix introduces you to some of the functions that the ALV makes
possible. However, this appendix does not cover the full breadth of ALV functionality.
For more information, refer to the ALV documentation in the R/3 online documentation:
R/3 Library → CA-Cross-Application Components → General Application Functions → ABAP
List Viewer
Guided Tour
This guided tour shows possible ways a user could interact with an ALV-enabled report list.
Technical Notes
In order for the reports to provide the consistency, flexibility, and user-friendliness of the
ALV, it is necessary to include certain statements in the report’s program code. This section
is intended for those who actually write the code for reports.
To include the ALV in a report, the following basic steps must completed:
1. Declare data areas for List Viewer.
2. Declare the internal table to store selected data.
3. Select data into internal table.
4. Build the field catalogs.
5. Build event catalogs.
6. Start ABAP List Viewer using SAP’s standard delivered function modules (see TechTalk
below).
7. Process call back events.
In the standard R/3 System, SAP delivers several function modules related to the ALV.
Use the following function modules with Release 4.0: REUSE_ALV_LIST_DISPLAY (this
is the primary function module) or other function modules that begin with the name
REUSE_ALV*.
Review the sample program on page A–10 which shows the coding related to each of steps
listed above.
Note: The source code that appears on page A–10 was used to create the sample ALV-
enabled report list presented in this appendix. You will find the source code
(ZFIGALV.txt) on the companion CD supplied with this guidebook series.
**************************************************************
REPORT ZFIGALV .
TYPE-POOLS: SLIS.
PERFORM BUILD_FIELDCAT.
PERFORM BUILD_FIELDCAT2.
PERFORM BUILD_FIELDCAT3.
PERFORM BUILD_SORTCAT.
PERFORM BUILD_SORTCAT2.
PERFORM BUILD_EVENTCAT.
***************************************************************
***************************************************************
*********FORM ROUTINES (Begin)*********************************
FORM BUILD_FIELDCAT.
ADD 1 TO COL_POS.
FIELDCAT_LN-REF_TABNAME = 'VBAP'.
FIELDCAT_LN-FIELDNAME = 'VBELN'.
FIELDCAT_LN-KEY = 'X'.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-COL_POS = COL_POS.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = 'X'.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM.
FORM BUILD_FIELDCAT2.
ADD 1 TO COL_POS.
FIELDCAT_LN-REF_TABNAME = 'VBAP'.
FIELDCAT_LN-FIELDNAME = 'MATNR'.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-COL_POS = COL_POS.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM.
FORM BUILD_FIELDCAT3.
ADD 1 TO COL_POS.
FIELDCAT_LN-REF_TABNAME = 'VBAP'.
FIELDCAT_LN-FIELDNAME = 'MATKL'.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = 'X'.
FIELDCAT_LN-COL_POS = COL_POS.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM.
FORM BUILD_SORTCAT.
SORTCAT_LN-SPOS = '1'.
SORTCAT_LN-FIELDNAME = 'MATNR'.
SORTCAT_LN-UP = 'X'.
SORTCAT_LN-DOWN = SPACE.
SORTCAT_LN-SUBTOT = 'X'.
APPEND SORTCAT_LN TO SORTCAT.
ENDFORM.
FORM BUILD_SORTCAT2.
SORTCAT_LN-SPOS = '2'.
SORTCAT_LN-FIELDNAME = 'VRKME'.
SORTCAT_LN-UP = SPACE.
SORTCAT_LN-DOWN = 'X'.
SORTCAT_LN-SUBTOT = SPACE.
APPEND SORTCAT_LN TO SORTCAT.
ENDFORM.
FORM BUILD_EVENTCAT.
EVENTCAT_LN-NAME = 'TOP_OF_PAGE'.
EVENTCAT_LN-FORM = 'PAGE_HEADER'.
FORM START_LIST_VIEWER.
DATA: PGM LIKE SY-REPID.
PGM = SY-REPID.
Review
< The ABAP List Viewer (ALV) functionality provided within ABAP can enhance reports
in the R/3 System, and was first made available with Release 3.1. The ALV is a set of
function modules added to program code. Programs created before this release can be
enhanced with the ALV by adding links to the function modules.
< Using the ALV provides a uniform user-interface and list format for ABAP reports. This
standardization helps eliminate redundant functions.
< Using the ALV enhances the functionality provided with reports while decreasing the
development time by roughly 40%.
< The ALV provides the following features:
Sorting
Resizing of rows
Double-clicking on one information element to jump to another information element
Performing basic calculations
Downloading of stylized spreadsheets
Displaying several colors
Visually separating various pieces of information on the screen
< To include the ALV in a report, the following basic steps must completed:
1. Declare data areas for List Viewer.
2. Declare the internal table to store selected data.
3. Select data into internal table.
4. Build field catalogs.
5. Build event catalogs.
6. Start the ABAP List Viewer using SAP’s standard delivered function modules.
7. Process call back events.