ALV (ABAP LIST VIEWER) Sap provides a set ofALV (ABAP LIST VIEWER) function modules, which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output.
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.
Sorting of records
Filtering of records
Totals and Sub-totals
Download the report output to Excel/HTML
Changing the order of the columns in the report
Hide the unwanted columns from the report
We have the following three ways to build a field catalog.
Automatically through a Data Dictionary structure.
Manually in ABAP program.
Semi-automatically by combining the above two procedures.
Declare an internal table of type SLIS_T_FIELDCAT_ALV.
Call function module REUSE_ALV_FIELDCATALOG_MERGE.
SLIS is the type library for ALV grid.
If you’ll use the ALV you have to add TYPE-POOLS : SLIS. command at the beginning of your code.
The user can programmatically set the initial (default) variant for list display.
The default variant can be found using the function module ‘REUSE_ALV_VARIANT_DEFAULT_GET’.
A list of possible events is populated into an event table (I_EVENTS) when this table is passed from the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
Display variants (only for hierarchical-sequential lists)
This internal table has the following fields:
Sops: Sort sequence.
Fieldname: Internal output table field name.
Tab name : Only relevant for hierarchical-sequential lists. Name of the internal output table.
Up: ‘X’ = sort in ascending order.
Down: ‘X’ = sort in descending order.
Sub tot : ‘X’ = subtotal at group value change.
Group: ‘* ‘ = new page at group value change ,’UL’ = underline at group value change.
What Are The Export Parameters Of Alv Reports Function Modules?
E_EXIT_CAUSED_BY_CALLER: Delete list in CALLBACK_USER_COMMAND
ES_EXIT_CAUSED_BY_USER: How the user left the list Tables
T_OUTTAB: Table with data to be displayed —mandatory
There are 2 type of reports:
In classic reports, we can see the output in single list where as in interactive reports we can see the output in multiple lists.
These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports:
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after processing user input still selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after processing selection screen.
END-OF-SELECTION: It is for Logical Database Reporting.
The user can Interact with the report. We can have a drill down into the report data.
We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
Events associated with Interactive Reports are:
TOP-OF-PAGE DURING LINE-SELECTION.
HIDE statement holds the data to be displayed in the secondary list.
sy-lisel : contains data of the selected line.
sy-lsind : contains the level of report (from 0 to 21)
Interactive Report Events:
AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sub list is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sub list.
AT PFn: For predefined function keys…
AT USER-COMMAND : It provides user functions keys.
TOP-OF-PAGE DURING LINE-SELECTION : Top of page event for secondary list.
Pricing Tables starts with A* like A001, A002, A900 like that.
KONH – Condition Header
KONP – Condition Detail
To allow users to maintain table using SM30 transaction you use Table Maintenance generator.
If you have MANDT as the first field that is Client Dependant table otherwise it is not. Usually most of the tables are client dependent. Only few like RFC Connections table (RFCDES), Batch Jobs (TBTCO and TBTCP) are not client dependant.
AT SELECTION-SCREEN OUTPUT is like Process Before Output Event. This would get triggered before screen is displayed. This can be used to make fields invisible/visible based on selection.
AT SELECTION-SCREEN: This would be triggered if you hit anything (Enter, Drop-Down, Help, Execute) after the selection screen is displayed.
CLEAR: It clears any field, structure or Header line of internal table.
REFRESH: Deletes all entries of internal table.
Create a variant in the ALV Report with whatever columns you would like to see and set sort criteria and column widths and save as a default variant.
You could get the default variant by calling FM REUSE_ALV_VARIANT_DEFAULT_GET
Create all the Domains and Data elements as needed using Txn SE11.
Start creating the table using Tcode SE11.
Maintain Delivery Class (A-Application Table, C-Customizing, etc)
Enter all the fields (MANDT must be the first field) and appropriate data elements or Built in Types for each field.
Make sure you select the Primary Key for this table.
Maintain the Technical Settings (Data class, Size, Buffering info)
Create Secondary indexes as needed
Activate the Table