Create a Simple SAP ALV Report

An ALV report is created using the standard function modules provided by SAP.

An ALV report can be created using the following steps.

  • Include SLIS type pool – SLIS type pool contains all the data types required by ALV function modules.
  • Data retrieval – Code the logic to fetch the data from database table into an Internal Table.
  • Build Field Catalog – Add the columns into an internal that you want to display in the ALV output list.
  • Pass the data table and field catalog table to ALV function module
TYPE-POOLS: slis.  " SLIS contains all the ALV data types

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: it_sbook     TYPE TABLE OF sbook.
DATA: it_fieldcat  TYPE slis_t_fieldcat_alv,
      wa_fieldcat  TYPE slis_fieldcat_alv.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.

*Fetch data from the database
  SELECT * FROM sbook INTO TABLE it_sbook.

*Build field catalog
  wa_fieldcat-fieldname  = 'CARRID'.    " Fieldname in the data table
  wa_fieldcat-seltext_m  = 'Airline'.   " Column description in the output
  APPEND wa_fieldcat TO it_fieldcat.

  wa_fieldcat-fieldname  = 'CONNID'.
  wa_fieldcat-seltext_m  = 'Con. No.'.
  APPEND wa_fieldcat TO it_fieldcat.

  wa_fieldcat-fieldname  = 'FLDATE'.
  wa_fieldcat-seltext_m  = 'Date'.
  APPEND wa_fieldcat TO it_fieldcat.

  wa_fieldcat-fieldname  = 'BOOKID'.
  wa_fieldcat-seltext_m  = 'Book. ID'.
  APPEND wa_fieldcat TO it_fieldcat.

  wa_fieldcat-fieldname  = 'PASSNAME'.
  wa_fieldcat-seltext_m  = 'Passenger Name'.
  APPEND wa_fieldcat TO it_fieldcat.

*Pass data and field catalog to ALV function module to display ALV list
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      it_fieldcat   = it_fieldcat
    TABLES
      t_outtab      = it_sbook
    EXCEPTIONS
      program_error = 1
      OTHERS        = 2.

Output

Create Simple ABAP ALV


15 thoughts on “Create a Simple SAP ALV Report

  • February 5, 2013 at 12:03 pm
    Permalink

    Hola Muchas gracias por este ejemplo salvaste mi vida 🙂

    Reply
  • May 29, 2013 at 10:58 am
    Permalink

    Hello 🙂 Thanks a bunch it was very helpful It’s been 2 days that I was trying to use ALVs in vain but now it is finally working

    Reply
  • September 4, 2013 at 10:43 am
    Permalink

    Excelente ejemplo¡¡¡¡

    Reply
  • June 6, 2014 at 12:09 pm
    Permalink

    Thank u for Making ABAP Easy..

    Reply
  • September 29, 2014 at 12:04 pm
    Permalink

    please help me

    Reply
  • September 29, 2014 at 12:04 pm
    Permalink

    how to create alv report

    Reply
  • December 12, 2014 at 5:02 pm
    Permalink

    Merci beaucoup

    Reply
  • August 5, 2015 at 9:31 am
    Permalink

    i created one ddic table after i write the alv reports as well as above document but i did not get output please tell me and give me reply please send any document adinarayana586@gmail.com

    Reply
  • April 29, 2016 at 10:15 am
    Permalink

    thanks admin….
    it’s realy very help full

    Reply
  • April 29, 2016 at 12:07 pm
    Permalink

    This is the best-est yet easiest ABAP tutorial on the internet till date !

    Reply
  • January 4, 2017 at 12:45 pm
    Permalink

    Thanks!!! Very Helpfull

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *