Alv Report Program to fetch data from custom table and display

Program:


REPORT ZSM_ALV_REPORT2.


type-POOLsslis.

TYPESBEGIN OF str,
  mandt TYPE mandt,
  id type id,
  name TYPE name,
   amount TYPE amount,
  currency TYPE currency,
  END OF str.

  DATAit TYPE STANDARD TABLE OF str,
        wa TYPE str.

  datait_fieldcat TYPE slis_t_fieldcat_alv,
        wa_fieldcat TYPE slis_fieldcat_alv.

  select mandt id name amount currency FROM zsm_tablez into TABLE it.


   wa_fieldcat-col_pos '1'.
  wa_fieldcat-fieldname 'MANDT'.
  APPEND wa_fieldcat to it_fieldcat.

    wa_fieldcat-col_pos '2'.
  wa_fieldcat-fieldname 'ID'.
  APPEND wa_fieldcat to it_fieldcat.


   wa_fieldcat-col_pos '3'.
  wa_fieldcat-fieldname 'NAME'.
  APPEND wa_fieldcat to it_fieldcat.


wa_fieldcat-col_pos '4'.
  wa_fieldcat-fieldname 'AMOUNT'.
  APPEND wa_fieldcat to it_fieldcat.


    wa_fieldcat-col_pos '5'.
  wa_fieldcat-fieldname 'CURRENCY'.
  APPEND wa_fieldcat to it_fieldcat.


  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                  =
*     I_BACKGROUND_ID                   = ' '
*     I_GRID_TITLE                      =
*     I_GRID_SETTINGS                   =
*     IS_LAYOUT                         =
     IT_FIELDCAT                       it_fieldcat
*     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                          it
   EXCEPTIONS
     PROGRAM_ERROR                     1
     OTHERS                            2
            .
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.


Post a Comment

0 Comments