ABAP List Viewer (ALV)
In this chapter you will learn:
Why the ABAP List Viewer (ALV) is useful
Some of the time-saving features of ALV, as well as its ability to enhance information display
The differences between reports written with and without the ALV
Technical information (sample code) to help you build reports with ALV “functionality”
Contents
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.
What Is The ABAP List Viewer?
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.
Goals of ALV The primary goals of the ABAP List Viewer are to provide:
Users with a consistent, user-friendly, and functional method of manipulating the data which appears on report lists.
ABAP developers with an efficient and consistent method of programming functions that are commonly needed or requested in reports.
ABAP List Viewer: Cost Versus Benefit Analysis
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
Finding the right tables and table relationships that need to be included in order for the program to be written 50%
Providing “fancy” features, such as sorting, subtotals, and interactivity 30%
Enhancing the look of the report with column headings, vertical lines, and color 20%
Total 100%
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
Finding the right tables and table relationships that need to be included in order for the program to be written 50%
Preparing field catalog and sort sequence for ALV 1%
Providing “fancy” features, such as sorting, subtotals, and interactivity 9%
Enhancing the look of the report with column headings, vertical lines, and color 0%
Total 60%
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.
Report Lists Without ABAP List Viewer
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
List data is “dead.” It is simply a so-called “data dump”
Function bar is blank
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:
Hint: These functions are all available in ALV Sort Resize rows Double-click on one information element to jump to another information element 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.
Report Lists With ABAP List Viewer
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)
List data is “alive”
Column headings make data easier to understand
A feature-rich function bar gives the user commonly requested functionality
Function bar is blank
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.
2
1In an ALV-enabled report list, a user can select a particular column and execute a subsequent function, if desired.
Select the column for Sales doc. With ALV’s added functionality the color of the selected column can be changed, making it easy for the report user to know which column has been selected.
Choose Filter. With the filter option, a user can call up a desired subset of information on the output list.
4
3Set the filter for the sales documents to be viewed. In this instance, the user only wants to views sales documents that are between the numbers 1000 and 2000.
Choose Copy to invoke the ALV to filter the list.
6
5The resulting filtered list is shown to the right. To return to the previous list, a user can simply click the arrow buttons without having to exit and re-execute the report.
If not all columns of the report are of interest to the user, the unwanted columns can be hidden. This can be accomplished by setting the current variant to include only the desired columns. To hide (or to view previously hidden columns), choose Display variant.
8
7In the popup window, the columns that currently appear in the list are shown in the left section. Hidden fields (if any) appear on the right section. In this example, all fields appear.
To make one column disappear, select the row which lists the column you want to hide. In this example, we select Material Group.
Then, click the single right-arrow button to move the selected column (Material group) to the hidden fields section.
9The Material Group is now one of the hidden fields.
For this change to take effect, choose Copy.
The “new” output list appears. The original list may be revisited by simply choosing the current variant.
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:
Declare data areas for List Viewer.
Declare the internal table to store selected data.
Select data into internal table.
Build the field catalogs.
Build event catalogs.
Start ABAP List Viewer using SAP’s standard delivered function modules (see TechTalk below).
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*.
K_KKB_LIST_DISPLAY is still available but should no longer be used!
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.
Sample Code Using ALV (Release 4.0B)
**************************************************************
REPORT ZFIGALV .
********Declare Data Areas for List Viewer (Begin)************
TYPE-POOLS: SLIS.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT,
SORTCAT TYPE SLIS_T_SORTINFO_ALV,
SORTCAT_LN LIKE LINE OF SORTCAT,
EVENTCAT TYPE SLIS_T_EVENT,
EVENTCAT_LN LIKE LINE OF EVENTCAT.
DATA: COL_POS TYPE I.
*******Declare Data Areas for List Viewer (End)***************
*******Declare Internal Table to Store Selected Data (Begin)**
DATA: BEGIN OF IVBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
MATKL LIKE VBAP-MATKL,
CHARG LIKE VBAP-CHARG,
KWMENG LIKE VBAP-KWMENG,
VRKME LIKE VBAP-VRKME,
ARKTX LIKE VBAP-ARKTX,
END OF IVBAP.
*******Declare Internal Table to Store Selected Data (End)****
*******Select Data into Internal Table (Begin) ***************
SELECT VBELN POSNR MATNR MATKL KWMENG VRKME
INTO CORRESPONDING FIELDS OF TABLE IVBAP
FROM VBAP WHERE VBELN NE 0.
******* Select Data into Internal Table (End) ****************
******* Build Field Catalogs (Begin)**************************
PERFORM BUILD_FIELDCAT.
PERFORM BUILD_FIELDCAT2.
PERFORM BUILD_FIELDCAT3.
PERFORM BUILD_SORTCAT.
PERFORM BUILD_SORTCAT2.
*******Build Field Catalogs (End)******************************
*******Build Event Catalog (Begin)*****************************
PERFORM BUILD_EVENTCAT.
*******Build Event Catalog (End)*******************************
*******Start List Viewer (Begin)*******************************
PERFORM START_LIST_VIEWER.
*******Start List Viewer (End)*********************************
***************************************************************
***************************************************************
*********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'.
APPEND EVENTCAT_LN TO EVENTCAT.
ENDFORM.
FORM START_LIST_VIEWER.
DATA: PGM LIKE SY-REPID.
PGM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = PGM
* i_callback_pf_status_set = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = SORTCAT
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
* IS_VARIANT = ' '
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* es_exit_caused_by_user =
TABLES
T_OUTTAB = IVBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
********Process Call Back Events (Begin)***************************
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE IVBAP INDEX SELFIELD-TABINDEX.
CHECK SY-SUBRC = 0.
CASE UCOMM.
WHEN '&IC1'.
CASE SELFIELD-SEL_TAB_FIELD.
WHEN 'IVBAP-VBELN'.
SET PARAMETER ID 'AUN' FIELD IVBAP-VBELN.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
WHEN 'IVBAP-MATNR'.
SET PARAMETER ID 'MAT' FIELD IVBAP-MATNR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
********Process Call Back Events (End)******************************
***********FORM ROUTINES (END)**************************************
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:
Declare data areas for List Viewer.
Declare the internal table to store selected data.
Select data into internal table.
Build field catalogs.
Build event catalogs.
Start the ABAP List Viewer using SAP’s standard delivered function modules.
Process call back events.
Where to Learn More
For more information, refer to the R/3 Library (online documentation).
In the HTML help documentation, go to:
R/3 System Library → CA-Cross-Application Components → General Application Functions → ABAP List Viewer
Friday, November 23, 2007
ABAP List Viewer (ALV)
Labels:
ABAP List Viewer (ALV)
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment