Create an ALV with FM REUSE_ALV_GRID_DISPLAY

Create an ALV with FM REUSE_ALV_GRID_DISPLAY

Abap code example to display an ALV with FM REUSE_ALV_GRID_DISPLAY.

Code below display MARA table data :

In TOP include, add slis type pool :


TYPE-POOLS : slis.

And then, use form, adapted with your table name :


FORM display_alv.

  DATA: ls_layout     TYPE slis_layout_alv,
        li_excluding  TYPE slis_t_extab.

  ls_layout-colwidth_optimize = 'X'.

  " Exclude useless buttons
  APPEND '&VEXCEL' TO li_excluding.
  APPEND '&AQW' TO li_excluding.
  APPEND '&RNT_PREV' TO li_excluding.
  APPEND '&GRAPH' TO li_excluding.
  APPEND '&INFO' TO li_excluding.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
      i_structure_name                  = 'MARA'
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
    is_layout                         = ls_layout
*   IT_FIELDCAT                       =
    it_excluding                      = li_excluding
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = gi_mara        " defined in another Form
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2
            .
  IF sy-subrc <> 0.
    MESSAGE 'Une erreur s''est produite dans l''affichage de la table.' 
            TYPE 'S' DISPLAY LIKE 'E'.
  ENDIF.

ENDFORM.                    "display_alv

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply