ALV Report with Structure in SAP ABAP

Developing ALV report with Structure in SAP ABAP using function module REUSE_ALV_GRID_DISPLAY

+ -
Requirement: 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

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 75 People out of 81 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →