Wednesday, April 25, 2012

ALV Report Without declaring Fieldcatalog :


*&---------------------------------------------------------------------*
*& Report  ZALV_AA_GRID
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZALV_AA_GRID.

TYPES : BEGIN OF TY_MARA,
        MATNR TYPE MATNR,
        MTART TYPE MTART,
        MBRSH TYPE MBRSH,
        MATKL TYPE MATKL,
        MEINS TYPE MEINS,
        END OF TY_MARA,
      TY_T_MARA TYPE STANDARD TABLE OF TY_MARA.

DATA : I_MARA TYPE TY_T_MARA,
       GV_MATNR TYPE MATNR.

DATA : I_ALV TYPE REF TO CL_GUI_ALV_GRID.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
  SELECT-OPTIONS : S_MATNR FOR GV_MATNR.
SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF SCREEN 9001.

SELECTION-SCREEN END OF SCREEN 9001.

SELECT MATNR
       MTART
       MBRSH
       MATKL
       MEINS
  INTO TABLE I_MARA
  FROM MARA
  WHERE MATNR IN S_MATNR.

CREATE OBJECT I_ALV EXPORTING I_PARENT = CL_GUI_CONTAINER=>SCREEN0.

          CALL METHOD I_ALV->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING I_STRUCTURE_NAME = 'MARA'
          CHANGING IT_OUTTAB = I_MARA.

           CALL SELECTION-SCREEN 9001.

No comments:

Post a Comment