ALV factory method with user defined types

ALV report with user defined types using Object Oriented Factory methods

+ -
When ever we use ALV factory methods to display ALV, we don`t need to create any field catalog, we can directly add our user defined tables instance as it automatically determine fields and displays.

Example program using ALV factory methods

REPORT ZSAPN_ALV_MARA_FACTARY.
TYPES: BEGIN OF TY_MARA,
        MATNR TYPE MARA-MATNR,
        MTART TYPE MARA-MTART,
        MBRSH TYPE MARA-MBRSH,
        MATKL TYPE MARA-MATKL,
        MEINS TYPE MARA-MEINS,
      END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA,
       WA_MARA TYPE MARA.
DATA : LR_ALV TYPE REF TO CL_SALV_TABLE.
SELECT MATNR MTART MBRSH MATKL MEINS FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS.

*  TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY "get SALV factory instance
*    EXPORTING
*      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*      R_CONTAINER    =
*      CONTAINER_NAME =
  IMPORTING
    R_SALV_TABLE = LR_ALV
  CHANGING
    T_TABLE      = IT_MARA.
*   CATCH CX_SALV_MSG .
*  ENDTRY.
LR_ALV->DISPLAY( ). "display grid

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 21 People out of 21 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →