Alv Reports
Alv Reports
Alv Reports
ALV REPORTS
• ALV stands for ABAP List Viewer. ALV gives us a standard List format and user
interface to all our ABAP reports. ALV is created by a set of standard function
modules provided by SAP.
• ALV takes care of rendering the list and we can concentrate only on the data
retrieval part.
Function modules used to create ALV reports
Function Module Description
1
Field catalog
• The field catalog is a table which contains information
on the fields to be displayed on the ALV output.
• First we need to build a field catalog before displaying
any output in the ALV
• We have the following three ways to build a field
catalog.
1. Automatically through a Data Dictionary structure.
2. Manually in ABAP program.
3. Semi-automatically by combining the above two
procedures.
2
• The third option is used in the following cases
– We want to display all the fields from the DDIC structure but
want to modify certain attributes like descriptions etc.
– We want to display most of the fields i.e. we want to hide certain
fields.
– Add new fields.
• To generate a field catalog semi-automatically
– Declare an internal table of type SLIS_T_FIELDCAT_ALV.
– Call function module REUSE_ALV_FIELDCATALOG_MERGE and pass the
DDIC structure of the output table and the internal table for the field
catalog. The function module generates the field catalog and fills the
internal table accordingly.
– Read the rows you want to change, and adapt the fields accordingly. If
your output table contains more fields than are stored in the Data
Dictionary, you must append one row for each new field to the field
catalog.
3
Display Header in ABAP ALV Grid
• Go to Transaction OAER,
• Give Class Name as PICTURES
• Class type as OT
• Object Key as the name of the Object u want to
specify
• Upon execution you would be prompted to give
the file path details. Just upload which ever logo u
want to display
• Now you can use the same name in your ALV FM
form top-of-page1.
wa-typ = 'S'.
data: header type slis_t_listheader, concatenate text-h01 sy-repid into wa-info
wa type slis_listheader. separated by space.
append wa to header.
* TITLE AREA
wa-typ = 'S'. ********" LOGO
wa-info = text-h04.
append wa to header. call function
'REUSE_ALV_COMMENTARY_WRITE'
wa-typ = 'S'.
write sy-datum to wa-info mm/dd/yyyy. exporting
• Build field catalog and set the field DO_SUM of field catalog to
‘X’ for the field for which you want calculate the totals.
• Pass field catalog to function module 6
‘REUSE_ALV_GRID_DISPLAY’.
• To calculate subtotal in ALV, build sort catalog and set the field
SUBTOT of sort catalog to ‘X’
wa_fieldcat-fieldname = 'PASSNAME'.
7
wa_fieldcat-seltext_m = 'Passenger Name'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'LOCCURAM'.
wa_fieldcat-seltext_m = 'Price'.
*Calculate Total for Price
8
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
Currency wise and Quantity wise Totals in SAP ALV
wa_fieldcat-fieldname = 'FORCURAM'.
• Fetch data from database table. wa_fieldcat-seltext_m = 'Price'.
• Build field catalog. wa_fieldcat-do_sum = 'X'.
wa_fieldcat-cfieldname = 'FORCURKEY'.
• To get the currency wise totals of APPEND wa_fieldcat TO it_fieldcat.
price, fill the CFIELDNAME field of
field catalog with the currency CLEAR wa_fieldcat.
column name and set do_sum to ‘X’. wa_fieldcat-fieldname = 'FORCURKEY'.
wa_fieldcat-seltext_m = 'Currency'.
• To get the quantity wise totals of APPEND wa_fieldcat TO it_fieldcat.
luggage, fill the QFIELDNAME field of CLEAR wa_fieldcat.
field catalog with the weight unit wa_fieldcat-fieldname = 'LUGGWEIGHT'.
wa_fieldcat-seltext_m = 'Weight'.
column name and set do_sum to ‘X’. wa_fieldcat-do_sum = 'X'.
• Pass field catalog to function module wa_fieldcat-qfieldname = 'WUNIT'.
‘REUSE_ALV_GRID_DISPLAY’. APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WUNIT'.
wa_fieldcat-seltext_m = 'Unit'.
8 APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
Display Traffic Lights in SAP ALV