Professional Documents
Culture Documents
| Edit Post
PERFORM GET_DATA_FROM_DATABASE .
*&---------------------------------------------------------------------*
" END-OF-SELECTION
" Steps to create simple ALV program
" ----------------------------------
" 1. Pass an internal table with the set of output information
" 2. Pass a field catalog as an internal table
" 3. Pass a structure with general list layout details
*&---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_EVENTS.
PERFORM BUILD_LAYOUT.
PERFORM DISPLAY_DATA.
*&---------------------------------------------------------------------*
" Form build_fieldcatalog
" Fieldcatalog Internal table
" --------------------------
" 1. It contains descriptions of the list output fields
" (usually a subset of the internal output table fields).
" 2. A field catalog is required for every ALV list output.
*&---------------------------------------------------------------------*
FORM BUILD_FIELDCATALOG .
CLEAR :
W_FIELDCAT,
I_FIELDCAT[].
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
FORM DISPLAY_DATA .
DATA :PROGRAM LIKE SY-REPID VALUE SY-REPID.
*&---------------------------------------------------------------------*
*& Form get_data_from_database
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_DATA_FROM_DATABASE .
CLEAR :I_MARD,
I_MARD[].
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
DATA :
I_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER LIKE LINE OF I_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-INFO = SY-TITLE.
APPEND W_HEADER TO I_HEADER.
CLEAR W_HEADER.
W_HEADER-TYP = 'H'.
W_HEADER-INFO = SY-REPID.
APPEND W_HEADER TO I_HEADER.
CLEAR W_HEADER.
ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT
*&---------------------------------------------------------------------*
W_FIELDCAT-FIELDNAME = L_FIELD.
W_FIELDCAT-TABNAME = L_TAB.
W_FIELDCAT-SELTEXT_M = L_TEXT.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_EVENTS-NAME = 'TOP_OF_PAGE'.
W_EVENTS-FORM = 'TOP_OF_PAGE'.
APPEND W_EVENTS TO I_EVENTS.
CLEAR W_EVENTS.
ENDFORM. " build_events
*&---------------------------------------------------------------------*
"& Form build_layout
" Layouts
" -------
" Use :We change the display of our list using layouts.
" ===
" Features
" ========
" The layouts that you can use vary according to the type of list:
" 1-->In all lists, you can do the following:
" (a).Choose one of the std layouts supplied with the std system.
" (b).Change the current layout of the list .
" 2-->In lists that use only the standard layouts in the std system
" you cannot save your changes to the current layout.When you
" choose the layouts, only the standard layouts will be proposed.
" 3-->In some lists, you can also save the layouts that you have
" defined as our own layouts.
" User-defined layouts are generally saved for all users. They can
" then be used by all users. All users will be able to choose from
" the user-defined layouts as well as the standard layouts.
" 4-->In some lists, you can also save user-specific layouts that you
" have defined . When you choose the current layout,only these
" layouts are available to you.
" 5-->You can delete or transport layouts, or define them as initial
" layouts
" 6-->STRUCTURE :SLIS_LAYOUT_ALV.
*&---------------------------------------------------------------------*
FORM BUILD_LAYOUT .
CLEAR:
W_LAYOUT.
W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " build_layout