Difference between class alv and function alv in SAP ABAP?


  • Class alv and Function alv are different in terms of features. Below is the difference:
  • Class alv are secured as compared to function alv.
  • While using class alv, it improves the performance.
  • With use of function alv, you can create screens using function module however you need to call separate programs to generate screen.
  • Class alv provides Object Oriented functionality and hence they are easily reusable.
  • You can execute function modules asynchronously and can also be called by other systems remotely.

Below is an example of class ALV:

DATA: lcl_alv TYPE REF TO cl_gui_alv_grid,
      t_gly TYPE STANDARD TABLE OF Travels .
SELECT * FROM Travels INTO TABLE t_gly.
CREATE OBJECT lcl_alv
    EXPORTING I_PARENT = cl_gui_container=>screen0.
CALL METHOD lcl_alv->set_table_for_first_display
    EXPORTING
       I_STRUCTURE_NAME = 'Travels'
    CHANGING
       IT_OUTTAB = t_gly.
CALL SCREEN 100.

 Few of function module to create ALV reports:

Sr.No
Function Module & Description
1
REUSE_ALV_LIST_DISPLAY
Display an ALV list
2
REUSE_ALV_GRID_DISPLAY
Display an ALV grid
3
REUSE_ALV_COMMENTARY_WRITE
Output list header information
4
REUSE_ALV_VARIANT_F4
Display variant selection dialog box
5
REUSE_ALV_VARIANT_EXISTENCE
Checks whether a variant exists
6
REUSE_ALV_FIELDCATALOG_MERGE
Create field catalog from dictionary structure or internal table

Below shows the use of function module to display an ALV grid:

DATA: it_spfli TYPE TABLE OF spfli.
SELECT * FROM spfli INTO TABLE it_spfli.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'SPFLI'
  TABLES
    t_outtab         = it_spfli.


Sharon Christine
Sharon Christine

An investment in knowledge pays the best interest

Updated on: 11-Dec-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements