Getting Started

Use

This section describes the easiest way to display a list with selected data in the ALV Grid Control. To do this, you must:

  1. Create an instance of the ALV Grid Control and integrate it into a screen.

  2. Select the data to be displayed and pass it together with a description of the fields to the instance.

Creating an ALV Grid Control

You instantiate an ALV Grid Control in the same way as other controls:

  1. Declare reference variables for the ALV Grid Control and the container. In addition, declare an internal table that you fill with selected data later on:

    DATA: grid TYPE REF TO cl_gui_alv_grid,
            g_custom_container TYPE REF TO cl_gui_custom_container
            gt_sflight TYPE TABLE OF sflight.
  2. Create a standard screen and mark an area for the custom container control in the graphical Screen Painter (icon identified by letter 'C'). Assign name CCCONTAINER to this area.

  3. In the PBO module of the screen, you must now instantiate the container control and the ALV Grid Control. By doing this, you create a link between the container control and the screen, using the container created in the Screen Painter. Using parameter parent, you define the container control as the parent of the ALV Grid Control:

    IF g_custom_container IS INITIAL.
    
            CREATE OBJECT g_custom_container
                    EXPORTING  CONTAINER_NAME = 'CCCONTAINER'.
            
            CREATE OBJECT GRID1
                    EXPORTING I_PARENT = g_custom_container.
    
    ENDIF.

When you start the program, although the two instances (the container control and the ALV Grid Control) are generated, they are not visible.

Displaying a List in the ALV Grid Control

Once you have created the ALV Grid Control and integrated it into a screen using a container control, you must pass the data and its structure to the ALV Grid Control:

  1. Fill the internal table with data:

    SELECT * FROM sflight INTO TABLE gt_sflight.
  2. Pass the output table and the structure data to the ALV Grid Control. Again, ensure to call this method only once after the ALV Grid Control is created:

    CALL METHOD grid->set_table_for_first_display
            EXPORTING I_STRUCTURE_NAME = 'SFLIGHT'
            CHANGING IT_OUTTAB = gt_sflight.