Classical ALV Reporting - Overview of ALV
Classical ALV Reporting - Overview of ALV
Classical ALV Reporting - Overview of ALV
Objectives
ABAP List Viewer (ALV) is a simple, user friendly and better looking reporting
tool as compared to the usage of write statements in a conventional / interactive
report.
SAP provides a set of ALV (ABAP LIST VIEWER) function modules, which can
be put into use to embellish the output of a report. This set of ALV functions are
used to enhance the readability and functionality of any report output.
Advantages of ALV
Looks better.
User friendly
Filtering / Sorting
Layout Change / Save
Summation, Download to excel, E-Mail
Data can be open for input / change etc.
Better Event handling
Width of more than 256 characters possible
Programming overhead of mentioning exact positions in write statements not
needed.
ALV Features
Change
Layout
Download to
Excel
Filtering
Sorting
Column
Heading
Row(s)
Selection
Display
Graphics
Fields
Open For
Input
ALV Programming
Three Approaches
Conventional (Using SAP Standard Function Modules).
Object Oriented (Using SAP Standard Classes and Methods).
Object model ( Using CL_SALV* classes ).
Step 2 : Selecting the Variant for initial list display (Default Variant).
Optional : Used only if report layout is maintained through variant management.
Step 4 : Build a table for Events, which are used for firing both user commands
and the system dependent events i.e. top of page, end of page etc.
Optional : Required if the report has custom buttons, interactive properties etc or you
need to display something at the top of page or end of page sections.
Step 8 : Prepare the final internal table that needs to be passed to the ALV
function module and display report output, using the following ALV functions
modules:
REUSE_ALV_LIST_DISPLAY
Or
REUSE_ALV_GRID_DISPLAY
SAP Standard tables types taken from the type pools are:
SLIS_LAYOUT_ALV ,
SLIS_T_FIELDCAT_ALV,
SLIS_T_LISTHEADER,
SLIS_T_EVENT,
SLIS_SELFIELD.
Internal tables to be used in the program declared based on the above table
types:
DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
I_HEADING TYPE SLIS_T_LISTHEADER,
I_EVENTS TYPE SLIS_T_EVENT.
TYPES: KKBLO_SELFIELD TYPE SLIS_SELFIELD.
Step 3 continued .
All the values entered in the catalog is specific to the particular field whose name
is entered in the field FIELDNAME of the field catalog structure. The name of the
table is also entered in the corresponding Fieldname TABNAME of the structure.
Some important attributes that can be defined for a field are:
Col_pos (column position)
Fieldname (field name)
Tabname (internal output table)
Ref_fieldname (reference field name)
Ref_tabname (reference table/structure field name
Link to currency unit
Cfieldname (currency unit field name)
Ctabname (internal currency unit field output table)
A layout is build for the report output description USING the internal table for
Layout (I_LAYOUT).
The layout parameters are described under the following heads:
Display options
Exceptions
Totals
Interaction
Detail screen
Color
Other
The Table IT_SORT is populated with the sort criteria for the different fields.
The caller specifies the Sorting and/or Subtotaling of the basic list in the internal
table IT_SORT.
This internal table has the following fields:
spos : Sort sequence
fieldname : Internal output table field name
tabname : Only relevant for hierarchical-sequential lists. Name of the internal output
table.
up : 'X' = sort in ascending order
down : 'X' = sort in descending order
subtot : 'X' = subtotal at group value change
group : '* ' = new page at group value change ,'UL' = underline at group value change
Finally display report output, using the following ALV functions modules:
REUSE_ALV_LIST_DISPLAY
OR
REUSE_ALV_GRID_DISPLAY
IMPORTING EXPORTING
I_CALLBACK_PROGRAM E_EXIT_CAUSED_BY_CALLER
I_CALLBACK_USER_COMMAND ES_EXIT_CAUSED_BY_USER
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_LIST_DISPLAY
I_STRUCTURE_NAME
TABLES
IS_LAYOUT
IT_FIELDCAT T_OUTTAB
IT_EXCLUDING
IT_SPECIAL_GROUPS
IT_SORT
IT_FILTER
IS_SEL_HIDE
I_DEFAULT
I_SAVE
IS_VARIANT
IS_PRINT
* Data to be displayed
DATA: I_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT.
* Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Result: REUSE_ALV_LIST_DISPLAY
Demonstration
Practice
REPORT Y_DEMO_ALV_GRID .
* Data to be displayed
DATA: I_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT.
* Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Result : REUSE_ALV_GRID_DISPLAY
Demonstration
Practice
Title
wa_fcat-col_pos = '4'.
wa_fcat-fieldname = 'PRICE'.
APPEND wa_fcat TO i_fcat.
Result :
PRICE
CONNID
FLDATE
CARRID
Demonstration
Creating a simple ALV report by populating the field catalog table, using the
function module REUSE_ALV_GRID_DISPLAY.
Practice
Creating a simple ALV report by populating the field catalog table, using the
function module REUSE_ALV_GRID_DISPLAY.
Custom Button
for adding extra
functionality
Demonstration
Creating a simple ALV report by changing the default status bar, using the
function module REUSE_ALV_GRID_DISPLAY.
Practice
Creating a simple ALV report by changing the default status bar, using the
function module REUSE_ALV_GRID_DISPLAY.
wa_fcat-col_pos = '4'.
wa_fcat-fieldname = 'PRICE'.
To make PRICE
wa_fcat-edit = 'X'.
field editable
Demonstration
Creating a simple ALV report by making one of its column editable, using the
function module REUSE_ALV_GRID_DISPLAY.
Practice
Creating a simple ALV report by making one of its column editable, using the
function module REUSE_ALV_GRID_DISPLAY.
Summary
ABAP List Viewer (ALV) is a simple, user friendly and better looking reporting tool
as compared to the usage of write statements in a conventional / interactive
report.
ALV report has several inbuilt User Friendly properties as:
Filtering / Sorting
Layout Change / Save
Summation, Download to excel, E-Mail
Data can be open for input / change etc.
The main ALV Function Modules are:
REUSE_ALV_LIST_DISPLAY
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_FIELDCATALOG_MERGE
Status STANDARD of the main program SAPLKKBL is copied and then changed
to create a new customized GUI status for any ALV report.
Questions
What is ALV ?
What are the main differences between an ALV report and a classical report?
What are the main function modules used to create an ALV List?
What are the main differences between ALV list and ALV grid?
What are the different ways to populate the FIELD CATALOG table?
How can we change the default status bar of an ALV List?
How can we handle custom function code in ALV ?
How can we make a certain columns of an ALV list editable?