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.

TRY.
    DATA(lo_grid) = 
      NEW cl_gui_alv_grid( 
          i_parent = cl_gui_container=>default_screen ).
    
    lo_grid->set_table_for_first_display(
                    EXPORTING i_structure_name = 'SBOOK'
                    CHANGING  it_outtab        = bookings ).
    CALL SCREEN 100.
  
  CATCH cx_root.
    WRITE 'Error Occurred'.
ENDTRY.

Then create a screen 0100 with absolutely nothing on it i.e. no custom container, create PF-STATUS and code to handle commands like EXIT, CANCEL and BACK.

When you run the ALV program, it displays in a full screen mode like below.

Visit ABAP Code Samples page for more code samples.


If you like the content, please subscribe…

Join 4,010 other subscribers

Discovering ABAP YouTube Channel