Professional Documents
Culture Documents
ALV
ABAP List Viewer is used to enhance the readability and functionality of any report
output. We can develop ALV using different ways like using type pool SLIS or using
the class Cl_GUI_ALV_GRID. In case of Object-Oriented concept, the Control
Framework is required as it provides global classes for various functionalities.
CL_GUI_ALV_GRID
It is the wrapper class implemented to encapsulate ALV Grid functionality for list
display. ALV Grid control is a flexible tool which provides following capabilities:
For building and displaying interactive, non-hierarchical and modern-design
lists.
1.
List Data : Data to be listed is populated in an internal table. This table can be
of any flat type
2.
Field Catalog: This is an internal table which contains the list of fields as per
specification. It comprises of some additional information about display options for
each column to be displayed. It must be referenced to the dictionary type
LVC_T_FCAT while the work-area should be of type LVC_S_FCAT. Function
LVC_FIELDCATALOG_MERGE can also be used to get field catalog by passing
structure name.
3.
ALV, where details list will be displayed in dialog box. For this functionality refer to
example BCALV_GRID_02.
4.
5.
OnDrag : This event is used to fetch information from the drag source.
successful drag and drop operation. For example: update the used internal table if a
row has been moved.NOTE: For Drag and Drop functionality refer to these standard
examples-BCALV_DND_01- Drag ALV row to Tree Folder
BCALV_DND_02- Drag Icons from Tree to rows of Grid
BCALV_DND_03- Drag & Drop on cells of grid
BCALV_DND_04- Drag & Drop within ALV Grid Control
BCALV_GRID_DND_TREE- ALV Grid: Drag and Drop with ALV Tree
BCALV_GRID_DND_TREE_SIMPLE- ALV Grid: Drag and Drop with ALV Tree (Simple)
6.
Additional Data: To trigger some additional features of ALV Grid we can have
some additional data to pass as parameters. For example, initial sorting criteria
(class used is LVC_S_SORT), buttons to be deactivated, GUI Status and title etc.
Populate the internal table that you want to display on the GRID.
For example:
This Internal table is filled with data from Sflight.
Data: t_sflight type standard table of Sflight.
Call the screen that contains Custom Container which is done at PBO of
screen.
Method SET_TABLE_FOR_FIRST_DISPLAY of class CL_GUI_ALV_GRID is
used to display the output.
For example:
CALL METHOD ob_grid->set_table_for_first_display
exporting
i_structure_name = SFLIGHT
is_layout = gs_layout
changing
it_outtab = T_SFLIGHT []
it_fieldcatalog = gt_fieldcat
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
repid = sy-repid
dynnr = sy-dynnr
side = g_dock1->dock_at_left
extension = 300.
CREATE OBJECT r_grid1
EXPORTING
i_parent = g_dock1.
ENDIF.
IF g_dock2 IS INITIAL.
CREATE OBJECT g_dock2
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock2->dock_at_bottom
extension = 100.
CREATE OBJECT r_grid2
EXPORTING
i_parent = g_dock2.
ENDIF.
Step2:
Take two internal tables and populate them with desired data.
For example:
it_tab, it_count.
Also fill the field catalog with corresponding structures of internal tables.
Step3:
Set internal table it_tab to grid r_grid1.
IF it_tab[] IS INITIAL.
CALL METHOD r_grid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = it_tab
it_fieldcatalog = gt_fieldcat.
ENDIF.
Step4:
Set internal table it_count to grid r_grid2.
IF NOT it_count[] IS INITIAL.
CALL METHOD r_grid2->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = it_count
it_fieldcatalog = gt_fieldcat1.
4
ENDIF.
Screen-shots for Output of ALV for displaying two internal tables in two different
Docking Containers along with Selection-screen:
we can display more than one internal table on the same screen as selectionscreen unlike ALV using Type-pool SLIS
Also we can filter records by putting in the selection screen and executing
the report as follows:
Click on Execute