Skip to end of metadata
Go to start of metadata


ALV display

Advanced List Viewer

The ALV Grid control is a flexible tool for displaying lists.
The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists.
The ALV Grid control provides typical list functions as sorting, filtering, summing, etc.,
while also gives the opportunity to develop user functions where needed.
It presents numerous interfaces like Excel Inplace and Crystal Reports.
The wrapper class implemented to encapsulate ALV Grid functionality is "CL_GUI_ALV_GRID".

While preparing a list to be displayed via an ALV grid control, we have some basic components to prepare. These are;
i. List data: Obviously, this is the data in an internal table to be listed. Standard ALV functions except sorting makes just read access to the list data. However, sorting changes state of the internal table. The internal table holding list data may be of any flat type. Deep types are only allowed when set for some functionalities of ALV Grid.
ii. Field Catalog: We use another internal table to define specifications on how the fields of our list will be displayed. This internal table is called the
"field catalog". The field catalog must comprise some technical and additional information about display options for each column to be displayed. There are three procedures to generate the field catalog as "Automatic generation", "Semi-automatic generation", and "Manual generation". The internal table for the field catalog must be referenced to the dictionary type "LVC_T_FCAT".
iii. Layout Structure: We fill a structure to specify general layout options for the grid. With this structure we can set general display options, grid customizing, totals options, color adjustments etc... The layout structure must be of type "LVC_S_LAYO".
iv. Event Handler: We should define and implement an event handler class if we want to handle events triggered by the ALV Grid instance. After creating ALV Grid instance, we must register an instance of this event handler class to handle ALV Grid events.
v. 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, buttons to be deactivated

Now lets start with a simple example program .

Step 1.
Create an object of class CL_GUI_CUSTOM_CONTAINER.

Step 2.
Create an object of class CL_GUI_ALV_GRID.

Step 3.
Populate the internal table that you want to display on the GRID.

Step 4.
Call the screen that contains the CUSTOM CONTAINER, in which you want to display the list .

Call the screen.

Create a custom container.

flow logic

Step 5.
Call the method SET_TABLE_FOR_FIRST_DISPLAY of class CL_GUI_ALV_GRID and pass the required parameters.

Program:

DATA:
T_SFLIGHT TYPE TABLE OF SFLIGHT,
FS_SFLIGHT TYPE SFLIGHT.
DATA:
R_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
R_GRID TYPE REF TO CL_GUI_ALV_GRID.
SELECT * FROM SFLIGHT INTO TABLE T_SFLIGHT.
CALL SCREEN 100.
&---------------------------------------------------------------------
*& Module STATUS_0100 OUTPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'SCREEN1'.
SET TITLEBAR 'TITLE1'.ENDMODULE. " STATUS_0100 OUTPUT
&---------------------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.&---------------------------------------------------------------------
*& Module LIST OUTPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MODULE LIST OUTPUT.
CREATE OBJECT R_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.CREATE OBJECT R_GRID
EXPORTING
I_PARENT = R_CONTAINER.
CALL METHOD R_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
IT_OUTTAB = T_SFLIGHT.
ENDMODULE.

Result:

back to top

  • No labels

5 Comments

  1. Hi,

       Me and my my participants where delighted to see the demo using this wiki nice work done. Thanks for the help.

    have a best day ahead.

  2. Nice document to  have a start up with OO concepts of ALV.

    5 stars.

  3. Nice document to  have a start up with OO concepts of ALV.

    5 stars.

  4. Former Member

    Hi Hareesh,

    None of pictures on this page and child pages can be seen or be loaded. Could you make them visible?

    Thanks and best regards,

    Wayne

  5. A good document, thank you.