ALV is very an useful tools in reporting. Just pass the data to ALV, than it will display interactive report easy to sort, filter, calculate total, etc.

There are two ALV model, list report (function REUSE_ALV_LIST_DISPLAY) and grid report (function REUSE_ALV_GRID_DISPLAY). Please read the function module documentation for complete guidance.

There are two main part of simple ALV report.
1. Create field catalog.
Field catalog containing descriptions of the list output fields.
2. Pass data and field catalog to ALV function (function REUSE_ALV_LIST_DISPLAY or REUSE_ALV_GRID_DISPLAY).

You can also playing with ALV format, find it in "Change Format in ALV".

This is a simple sample of how to use ALV.


    REPORT ZAALGAL0001.
    *-----------------------------------------
    *Data declaration
    TABLES: mara,
    makt.

    * Data output
    DATA: BEGIN OF t_report OCCURS 3,
    matnr LIKE mara-matnr,
    mtart LIKE mara-mtart,
    maktx LIKE makt-maktx,
    END OF t_report.

    * Field desciption / field catalog
    TYPE-POOLS: SLIS.
    data t_fcat type SLIS_T_FIELDCAT_ALV.

    *-
    DATA: d_repid LIKE sy-repid.

    *-----------------------------------------
    *--Selection Screen
    SELECT-OPTIONS: s_matnr FOR mara-matnr,
    s_mtart FOR mara-mtart.

    *-----------------------------------------
    START-OF-SELECTION.
    *-Read data
    SELECT * FROM mara
    WHERE matnr IN s_matnr AND
    mtart IN s_mtart.
    CLEAR makt.
    SELECT SINGLE *
    FROM makt
    WHERE matnr = mara-matnr AND
    spras = sy-langu.
    MOVE: mara-matnr TO t_report-matnr,
    mara-mtart TO t_report-mtart,
    makt-maktx TO t_report-maktx.
    APPEND t_report.
    ENDSELECT.

    IF sy-subrc NE 0.
    WRITE 'No data found'.
    EXIT.
    ENDIF.

    *-----------------------------------------
    *-Create Field Catalog

    * Store report name
    d_repid = sy-repid.

    * Create Fieldcatalogue from internal table
    * Use capital letter for I_INTERNAL_TABNAME
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = d_repid
    I_INTERNAL_TABNAME = 'T_REPORT'
    I_INCLNAME = d_repid
    CHANGING
    CT_FIELDCAT = t_fcat
    EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3.

    IF SY-SUBRC <> 0.
    write: / 'Error:',sy-subrc,
    'when Create Field Catalog'.
    EXIT.
    ENDIF.

    * Call ALV List Display
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = d_repid
    IT_FIELDCAT = t_fcat
    TABLES
    T_OUTTAB = t_report
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.

    IF SY-SUBRC <> 0.
    write: / 'Error:',sy-subrc,
    'when Call ALV List Display'.
    EXIT.
    ENDIF.



Serkan AKKAVAK
Computer Engineer
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com