Program For Using REUSE_ALV_GRID_DISPLAY

Simple ALV Program using REUSE_ALV_GRID_DISPLAY

*&---------------------------------------------------------------------*
*& Report  ZSAN_ALV1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ZSAN_ALV1.
TYPE-POOLS : SLIS.
TYPES : BEGIN OF T_TYPE,  "user defined type
            A TYPE I,
            B TYPE I,
        END OF T_TYPE.
DATA : GT_TYPE TYPE STANDARD TABLE OF T_TYPE,   "table of user defined type
       GS_TYPE TYPE T_TYPE.
DATA : GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,   "table of slis type-pool to show alv modifications
       GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
START-OF-SELECTION.
       DO 5 TIMES.
         GS_TYPE-A = SY-index.
         GS_TYPE-B = SY-index ** 2.
         APPEND GS_TYPE TO GT_TYPE.
       ENDDO.
END-OF-SELECTION.
      GS_FIELDCAT-FIELDNAME = 'A'.    " defininf fields in ALV report
      GS_FIELDCAT-TABNAME   = 'GT_TYPE'.
      GS_FIELDCAT-SELTEXT_S = 'Number'.
      GS_FIELDCAT-SELTEXT_m = 'Number'.
      GS_FIELDCAT-SELTEXT_L = 'Number'.
      GS_FIELDCAT-do_sum    = 'X'.
      APPEND GS_FIELDCAT TO GT_FIELDCAT.
      CLEAR GS_FIELDCAT.
            GS_FIELDCAT-FIELDNAME = 'B'.
      GS_FIELDCAT-TABNAME   = 'GT_TYPE'.
      GS_FIELDCAT-SELTEXT_S = 'Number2'.
            GS_FIELDCAT-SELTEXT_m = 'Number2'.
      GS_FIELDCAT-SELTEXT_L = 'Number2'.
      APPEND GS_FIELDCAT TO GT_FIELDCAT.
*      GS_FIELDCAT-FIEL

call function 'REUSE_ALV_GRID_DISPLAY'  " call fn to display in ALV format
 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                  = 'T_TYPE'  "type of structure according to which display is to be done
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
    IT_FIELDCAT                       = GT_FIELDCAT "ALV table to indicate formatting
*   IT_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                          = GT_TYPE   "name of table from which data is reported
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

See Also:
Ways To Create Internal Table

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.