Quick Contact

    SAP Tutorial
    Sap FI

    ABAP ALV Reports

    ALV (ABAP List Viewer) is per-defined report format in SAP.

    Advantages of ALV Reports

    • Better look and feel.
    • ALV report consists of some per-defined options like sort, filters, sum, downloading, print, changing the layout structure and many more.

    List of Function Modules used to develop ALV reports

    The below are the list of Function Modules we use to display ALV reports in different formats.

    REUSE_ALV_GRID_DISPLAY. "Display ALV grid format
    REUSE_ALV_LIST_DISPLAY. "Display ALV List format 
    REUSE_ALV_COMMENTARY_WRITE. "Display Top of page, logo, etc.
    REUSE_ALV_FIELDCATELOGUE_MERGE. "Used to generate field catalogue
    REUSE_ALV_EVENTS_GET. "Use events in ALV
    REUSE_ALV_HEIRARCHY_LIST_DISPLAY. "Display ALV Hierarchy 
    REUSE_ALV_BLOCKED_LIST_DISPLAY. "Display blocked list
    

    ALV Report with Structure

    Develop an ALV report to display material details with all fields from MARA table for a material range input(Select-Options input).

    In this requirement, we have to display all fields from MARA (Material master table) in ALV format. We use REUSE_ALV_GRID_DISPLAY Function module to display an ALV report.

    Steps to create ALV Report with Structure.

    Step1:

    Declare Internal table for MARA table.

    Step2:

    Print Select-Options.

    Step3:

    Get data from database using select statements.

    Step4:

    Call Function Module REUSE_ALV_GRID_DISPLAY and pass structure name, program name and internal table name.

    TABLES : MARA. "DECLARE TABLE FOR SELECT-OPTIONS
    DATA : IT_MARA TYPE TABLE OF MARA. "DECLARE INTERNAL TABLE FOR MARA
    DATA : WA_MARA TYPE MARA.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "PRINT SELECT-OPTIONS FOR MATNR
    START-OF-SELECTION.
    SELECT * FROM MARA INTO TABLE IT_MARA
                       WHERE MATNR IN S_MATNR .
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "CALL FUNCTION MODULE TO DISPLAY ALV GRID
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID "SY-REPID IS A SYSTEM VARIABLE WHICH STORES CURRENT PROGRAM NAME
    I_STRUCTURE_NAME = 'MARA'
    TABLES
    T_OUTTAB = IT_MARA. "PASS INTERNAL TABLE TO DISPLAY ALV FORMAT
    

    The above report after modularization

    The one below is the full report after using modularization techniques.

    *&---------------------------------------------------------------------*
    *&Report  ZALV_STR
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ZALV_STR.
    TABLES: MARA.
    DATA : IT_MARA TYPE TABLE OF MARA .
    
    
    SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
    
    START-OF-SELECTION .
      PERFORM GET_MARA_DATA . "Double click to create below form
    
    END-OF-SELECTION .
      PERFORM DISP_MARA_ALV . "Double click to create below form
    
    *&---------------------------------------------------------------------*
    *&Form  GET_MARA_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <-- p2 text *----------------------------------------------------------------------* FORM GET_MARA_DATA . SELECT * FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR . ENDFORM. " GET__MARA_DATA *&---------------------------------------------------------------------* *&Form DISP_MARA_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DISP_MARA_ALV .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-REPID
          I_STRUCTURE_NAME   = 'MARA'
        TABLES
          T_OUTTAB           = IT_MARA.
    
    ENDFORM.                    " DISP_MARA_ALV
    

     

    Apply now for Advanced SAP Course

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.