Creating ALV is probably the most recurring phenomenon in ABAP world. With REUSE_ALV_GRID_DISPLAY becoming a ‘thing in a past’, we now use either CL_SALV_TABLE or CL_GUI_ALV_GRID.

When we create ALV with the class CL_GUI_ALV_GRID we usually create a custom container without really understanding its use.

The custom container should be used to show something like ALV or PDF on part of the screen. If you do not want to divide the screen you don’t need containers.

A simple full screen ALV can easily be created with below code.

SELECT * FROM sbook INTO TABLE @DATA(bookings).

    DATA(lo_grid) = 
      NEW cl_gui_alv_grid( 
          i_parent = cl_gui_container=>default_screen ).
                    EXPORTING i_structure_name = 'SBOOK'
                    CHANGING  it_outtab        = bookings ).
    CALL SCREEN 100.
  CATCH cx_root.
    MESSAGE 'Error in ALV creation' TYPE 'E'.

Just create a screen 0100 with absolutely nothing on it i.e. no custom container and you are good to go. You need to handle PS-STATUS separately, but this post is not about PF-STAUS.

Visit ABAP Code Samples page for more code samples.

If you like the content, please subscribe…

Join 2,647 other followers