Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Contents
Introduction..................................................................................................................2 Different Kinds of ALV outputs.....................................................................................3 Features of ALV............................................................................................................4 Benefits of ALV.............................................................................................................5 Steps to create a simple ALV Report............................................................................6 Initialize ALV..........................................................................................................8 Setting the ALV Layout..........................................................................................9 Layout Settings...............................................................................................9 Setting Field Catalog...........................................................................................16 Generating field catalog Automatically.........................................................18 Generating field catalog Manually................................................................18 Generating field catalog Semi-Automatically................................................18 Field Catalog Settings...................................................................................19 Setting Sort criteria.............................................................................................27 Sort Settings.................................................................................................27 Grid Settings........................................................................................................29 Grid Settings.................................................................................................29 Grid Title.......................................................................................................29 Events in ALV......................................................................................................30 PF-STATUS in ALV.........................................................................................32 Variants in ALV.............................................................................................32 Filter Settings......................................................................................................33 Display ALV.........................................................................................................34 ...........................................................................................................................36
Introduction
What is ALV? Page 2 of 36
Application List Viewer/ALV Grid Control (ALV = SAP List Viewer) ALV is an output list viewer/control which is a more flexible/interactive tool for displaying lists. This is more user friendly than ordinary list output. More over, ALV grid control has built in functionalities like sorting, filtering, summing, etc. It also allows user to develop user defined buttons/function codes. It presents numerous interfaces like Excel and Crystal Reports.
The wrapper class implemented to encapsulate ALV Grid functionality is CL_GUI_ALV_GRID. There is another way to display lists with ALV utilizing REUSE_ALV... functions. Here in this document, we will see about how to implement an ALV using REUSE_ALV functions.
Page 3 of 36
Features of ALV
Built-in functionality Page 4 of 36
a. Sorting b. Summing c. Subtotals d. Filtering e. Download to external applications f. Excel, Word, Text,etc Navigation to SAP transactions Standardized Report Presentation a. ALV Grid Presentation b. ALV List Presentation
Sort
Filter
Total
Local File
Print Prev
Excel
Word
Benefits of ALV
o Reduced Report Development Time and Cost
Page 5 of 36
Developer doesnt have to spend as much time on report layout (columns, spacing, sorting, totals, subtotals). More users friendly
The following are the steps to create a simple ALV Report, Initialize ALV Control Setting the ALV Layout Setting up the field catalog for the presentation of columns Setting up the Sort criteria to be applied in the output Setting up the Grid settings if the output is needed in Grid format Setting up ALV events and customize each event according to need Filter settings on the output Display the ALV output with defined settings
The above mentioned steps are common for both ALV creation methods (through class CL_GUI_ALV_GRID or through REUSE_ALV function module). The general template which we can follow to develop any method of ALV report is
************************ Initiate ALV ***************************** * Initialization to display ALV in block mode PERFORM init_alv. * ALV Grid setting. PERFORM grid_setting USING gs_grid_settings. ********************** Layout setting logic *********************** * Build a layout for the ALV Grid. PERFORM layout_init USING gs_layout. ******************* Field List Catalog logic ********************** * Load field list catalog for detailed structure MOVE gc_fcat_structure TO gv_fcat_structure. * Build field catalog for ALV display PERFORM fieldcat_build CHANGING gt_fcat[]. ********************* Set field option logic ********************** * Set field options for ALV display PERFORM customize_fieldcatalog CHANGING gt_fcat[]. ********************* Sort settings logic ************************* * Sort settings for the ALV output. PERFORM sort_output TABLES gt_sort_list. * Build List Header for EVENT Top-of-Page. PERFORM comment_build USING gt_top_of_page[]. * Build an Event table PERFORM eventtab_build USING gt_events[]. ********************** Display ALV ******************************* * Display The ALV PERFORM display_alv .
Page 7 of 36
Initialize ALV
This is the initial step where the ALV control is initialized using the FM:REUSE_ALV_BLOCK_LIST_INIT
*&-----------------------------------------------------------------* *& Form init_alv * *&-----------------------------------------------------------------* * Initialize ALV Grid * *&-----------------------------------------------------------------* FORM init_alv. DATA lv_repid LIKE sy-repid. CLEAR lv_repid. lv_repid = sy-repid. CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT' EXPORTING i_callback_program = lv_repid. ENDFORM.
The import and export parameters for the FM: REUSE_ALV_BLOCK_LIST_INIT is as follows:
FUNCTION REUSE_ALV_BLOCK_LIST_INIT. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID *" VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME *" DEFAULT SPACE *" VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME *" DEFAULT SPACE *" VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL *"----------------------------------------------------------------------
The ALV report name should be passed as the value for the import parameter i_callback_program.
Page 8 of 36
Layout Settings
The following are some of the most important layout settings.
Field name CTAB_FNAME Short description Field name of table with cell color codes Optimize column width Purpose Field name in output table for coloring cells If this field is set, the ALV Grid Control optimizes the column width. You can then see the column header and the contents of the cells of this column. Value Range Character string of 30 characters at most
CWIDTH_OPT
SPACE, 'X'
DETAILINIT
If this field is set, the detail screen also shows columns with initial values.
SPACE, 'X'
DETAILTITL
GRID_TITLE
Title between
Page 9 of 36
INFO_FNAME
KEYHOT
Field name in output table for coloring rows If this field is set, all key fields are hotspotsensitive. If a key field is clicked once, event hotspot click is triggered.
SPACE, 'X'
NO_HEADERS
SPACE, 'X'
NO_HGRIDLN
If this field is set, columns are displayed without horizontal grid lines.
SPACE, 'X'
NO_MERGING
If this field is set, cells are not merged when a column is sorted.
SPACE, 'X'
NO_ROWMARK
If this field is set, the button at the beginning of a row is hidden in selection
SPACE, 'X'
Page 10 of 36
modes cell selection ( SEL_MODE = 'D' ) and column/row selection ( SEL_MODE = 'A' ).
NO_TOOLBAR
Hide toolbar
SPACE, 'X'
NO_TOTARR
The ALV Grid Control displays arrows in the totals line and the subtotals line that additionally indicate the totalling area. Set this parameter to suppress these arrows.
SPACE, 'X'
NO_TOTEXP
An icon displayed at the beginning of a (sub)totals line indicates whether the line has been expanded or not. Set this parameter to suppress this icon.
SPACE, 'X'
NO_TOTLINE
Do not display
SPACE, 'X'
Page 11 of 36
totals line
NO_VGRIDLN
If this field is set, columns are displayed without vertical grid lines.
SPACE, 'X'
NUMC_TOTAL
If this field is set, the user can calculate totals for fields of data type NUMC (normally, users are not allowed to do this).
SPACE, 'X'
S_DRAGDROP
SEL_MODE
Selection mode
SPACE, 'A', 'B', 'C', 'D' Value SPACE 'A' Mode same as 'B' Column and row selection (see graphic) Possible selections see 'B' Comment Default setting The user selects the rows through pushbuttons at the left border of the grid control.
'B'
Page 12 of 36
'C'
Multiple columns Multiple rows Multiple columns Multiple rows Any cells
'D'
Cell selection
The user selects the rows through pushbuttons at the left border of the grid contro
SGL_CLK_HD
Enables the single click on column header function. This function sorts the list in ascending order when the column is clicked for the first time, and then in descending order when the column is clicked a second time.
SPACE, 'X'
TOTALS_BEF
If this field is set, the ALV displays totals calculated as the first rows in the grid control. Subtotals are displayed before a new value of the subtotals criterion.
SPACE, 'X'
Page 13 of 36
ZEBRA
If this field is set, the list shows a striped pattern in the print preview and when it is printed.
SPACE, 'X'
Page 14 of 36
This configured layout structure (xy_layout TYPE slis_layout_alv) is then passed to import parameter is_layout of the REUSE_ALV FM.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = lv_repid i_grid_title = lv_alv_title i_grid_settings = gs_grid_settings is_layout = gs_layout it_fieldcat = gt_fcat i_default = gc_true i_save = 'A' it_sort = gt_sort_list TABLES t_outtab = gt_output_display EXCEPTIONS program_error =1 OTHERS = 2.
Page 15 of 36
Page 16 of 36
The output structure name and field catalog internal table is passed to i_structure_name and ct_fieldcat of FM: REUSE_ALV_FIELDCATALOG_MERGE respectively. REUSE_ALV_FIELDCATALOG_MERGE: This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure_name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it. The important parameters are: 1. Export: a. I_program_name : report id b. I_internal_tabname : the internal output table c. I_inclname : include or the report name where all the dynamic forms are handled. 2. Changing ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is declared in the type pool SLIS.
Page 17 of 36
Page 18 of 36
CHECKBOX
Output as checkbox
Outputting a checkbox. The checkbox cannot be modified by the user. Parameter sel_mode of the layout structure allows the user to select multiple rows in the grid control You can only access this field in readonly mode. As of Release 4.6C, this field is used (instead of the field name) to access columns of the output table. Relevant only if the relative column positions should not be identical to the sequence of fields in the field catalog when the list is displayed for the first time. The parameter determines the relative column position of the field for list output. The user can interactively modify the order of the columns. If this parameter is initial for each field catalog entry, the order of the columns corresponds to the sequence of fields in the field catalog.
SPACE, 'X'
COL_ID
COL_POS
Number
Number
COLDDICTXT
Relevant only to fields with reference to the Data Dictionary. You use values 'L', 'M', 'S' or 'R' to determine if SCRTEXT_L , SCRTEXT_M, SCRTEXT_S or REPTEXT is used as the column header.
COLTEXT
Determines the column header of the column. You should assign a value to this field if it does not have a Data
Page 19 of 36
Dictionary reference.
CURRENCY
Currency unit
Explicitly specifying a currency (such as DEM , USD ). The ALV displays the values for the column specified in FIELDNAME according to the conventions for this currency.
name of a currency
DD_OUTLEN
You use this field to specify the field output length for external display. This is only relevant to fields without reference to the Data Dictionary for which you want to modify the output using a conversion exit The column width (field OUTPUTLEN of the field catalog) does not need to be identical to the output length for external display ( DD_OUTLEN ).
0 (initial), n
DECIMALS_O
Relevant only if no currency field is assigned to the field and if CURRENCY has a value. The value in this field determines the number of digits to be displayed after the comma.
DECMLFIELD
Defining the digits after the comma on a row-by-row basis. You can use an additional field in the output table to determine how many digits are to be displayed after the comma in each row.
DO_SUM
If this field is set, the ALV uses this field to calculate the total (this corresponds to the generic totals function in the toolbar.)
SPACE, 'X'
DRAGDROPID
Drag & Drop handle for Drag & Drop object EditMask for output
You use this field to define a D&D Behavior for Special Columns.
EDIT_MASK
EMPHASIZE
Column color
If you set a conversion exit (for example, conv = ' ==ALPHA ' for function module CONVERSION_EXIT_ALPHA_OUTPUT ), you enforce output conversion for the associated output field. If the field is set to 'X', the ALV uses a pre-defined color for highlighting the column. If the character field begins with 'C' (color code), the remaining numbers
Page 20 of 36
EXPONENT Exponent for float representation
Determines a fixed exponent for the field. The field must be of internal type F. (See also F1 help for WRITE edit option EXPONENT ).
initial, integer
FIELDNAME
You use this field to assign a field name of your output table to a row of the field catalog. All settings that you make in this row refer to the corresponding column of the output table.
HOTSPOT
Single-click sensitive
SPACE, 'X'
HREF_HNDLE ICON
INTLEN
INTTYPE
Handle to which an URL is assigned. The ALV Grid Control displays all cells of the column as hyperlinks If this field is set, the column contents of the output table are output as an icon. The column contents must consist of valid icon strings ( @xx@ or @xx\Q <Quickinfo> @ ). You use this field to specify the field output length for internal display. This is only relevant to fields without reference to the Data Dictionary, for which you want to modify the output using a conversion exit Only required for field without reference to the Data Dictionary.
0 (initial), n
ABAP data type, see value range of domain INTTYPE SPACE, 'R', 'L','C'
JUST
How the column header is justified, depends on how the column contents are justified. You cannot justify the column header separately.
Page 21 of 36
KEY
Key column
LOWERCASE LZERO
If this field is set, the ALV Grid Control color-codes the column as a key field and fixes this column during horizontal scrolling. The order of the key columns in the ALV Grid Control can be modified interactively. In contrast to the SAP List Viewer, the ALV Grid Control allows you to directly hide key columns with NO_OUT If this field is set, the ALV Grid Control recognizes upper/lower case in the output table. Relevant only to fields of data type NUMC . In the default setting, the ALV Grid Control displays these fields right justified without leading zeros. If you set LZERO , leading zeros are displayed.
SPACE, 'X'
NO_MERGING
If this field is set, cells with the same value are not merged into a single cell when this column is sorted.
SPACE, 'X'
NO_OUT
If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid control.
SPACE, 'X'
NO_SIGN NO_SUM
Supress sign in display No totals calculation for column values Suppress zeros in display
Relevant only to value fields. If you set NO-SIGN , values are displayed without signs If you set this field, you lock totals calculation for the relevant field.
NO_ZERO
If NO_ZERO is set, no zeros are displayed for initial value fields. The cell remains empty.
SPACE, 'X'
OUTPUTLEN
0 (default setting), n
If the field has a reference to the Data Dictionary, you can leave the field set to its initial value. In this case, the ALV adopts the output length of the relevant
Page 22 of 36
domain. For fields without reference to the DDIC, you must specify the desired field output length.
QFIELDNAME
Defining a reference to quantity units. The ALV links the field specified in FIELDNAME to the field for quantity units specified in QFIELDNAME . The field specified in QFIELDNAME must have a separate entry in the field catalog.
QUANTITY
Quantity unit
Explicitly specifying a unit (such as KG ). The ALV displays the values for the column specified in FIELDNAME according to the conventions for this unit.
REF_FIELD
the output table field described by the current entry in the field catalog has a corresponding field in the Data Dictionary and the field name in the output table is not identical to the field name of the field in the Data Dictionary.
SPACE, name of a field in the Data Dictionary that corresponds to a field in the output table
If the field names are identical, it is sufficient to specify the DDIC structure or table in field REF_TABLE of the field catalog.
REF_TABLE
You must fill this field only if the output table field described by the current entry in the field catalog has a corresponding entry in the Data Dictionary. Using this assignment, the ALV Grid Control can copy the text for the column header from the Dictionary, for example.
SPACE, name of a structure or table from the Data Dictionary that corresponds to a field in the output table.
REPREP
'X' = if the report/report interface is called, the value of this field is passed in the selected jump line of the interface as a selection criterion.
SPACE, 'X'
Page 23 of 36
REPTEXT
Relevant only to fields with reference to the Data Dictionary. For such fields, the ALV Grid Control copies the field label for the header of the corresponding data element into this field.
ROLLNAME
If you want to provide F1 help for an output field without Data Dictionary reference or if you want to define a different F1 help than that stored in the DDIC for a field with DDIC reference, you can use this field. If F1 help is called for this field, the documentation for the data element assigned is displayed. If ROLLNAME is initial for fields with Data Dictionary reference, the documentation for the data element of the referenced field of the Data Dictionary is displayed.
ROUND
ROUND value
ROUNDFIELD
Displaying a value of type P scaled by the power of ten. For positive ROUND values, the ALV Grid Control moves the comma to the left; otherwise, it moves the comma to the right. Defining scaled output on a row-by-rowbasis. You can use an additional field in the output table to determine how the relevant field is scaled in each row.
SCRTEXT_L
Relevant only to fields with reference to the Data Dictionary. For such fields, the ALV Grid Control copies the long field label of the corresponding data element into this field.
SCRTEXT_M
Relevant only to fields with reference to the Data Dictionary. For such fields, the ALV Grid Control copies the medium field label of the corresponding data element into this field.
SCRTEXT_S
Relevant only to fields with reference to the Data Dictionary. For such fields, the ALV Grid Control copies the short field label of the corresponding data element into this field.
Page 24 of 36
SELDDICTXT
Relevant only to fields with reference to the. You use values 'L', 'M', 'S' or 'R' to determine if SCRTEXT_L , SCRTEXT_M , SCRTEXT_S or REPTEXT is used as the text for column selection.
SELTEXT
Determines the text to be used in the column selection for the column. You should assign a value to this field if it does not have a Data Dictionary reference.
SP_GROUP
Group key
SYMBOL
Output as symbol
You use the group key to group several fields together. On the dialog box for defining a layout, the user can then limit the list of hidden columns to this group. If this field is set, the column contents are displayed as a symbol. The column contents of the internal table must consist of valid symbol signs. The caller should consider the problem of printing symbols. (It is usually possible to print symbols, but they may not be output correctly depending on the printer configuration).
TECH
Technical fields
If this field is set, the relevant field is not displayed on the list and cannot be shown interactively. The field is only known in the field catalog. (For example, it must not be specified as a sorting criterion).
SPACE, 'X'
TIPDDICTXT
Relevant only to fields with reference to the Data Dictionary. You use values 'L', 'M', 'S' or 'R' to determine if SCRTEXT_L , SCRTEXT_M , SCRTEXT_S or REPTEXT is used as the tool tip.
TOOLTIP
Determines the text to be used as the tool tip for the column. You should assign a value to this field if it does not have a Data Dictionary reference.
TXT_FIELD
You can use this field to define a reference to a field that is used as the description for the current field. If a subtotal is calculated for the current
Page 25 of 36
field, the ALV Grid Control displays the descriptions in the field assigned.
WEB_FIELD
Page 26 of 36
Finally , the internal table with sort settings is passed to the import parameter it_sort of the display ALV FM to output as defined in sort settings.
Sort Settings
The following are some important sort settings options available.
Field name SPOS FIELDNAME UP DOWN SUBTOT GROUP Description Sort order if the list is sorted by multiple columns Field name in the internal output table 'X' = Sorted in ascending order 'X' = Sorted in descending order 'X' = Subtotal at group level change Once a column is sorted, it is subdivided into groups. This means there is one group for each value of the column (in the default setting, the ALV Grid Control merges cells that have the same value in the sort column). If the value in the sort colulmn changes, this is called a group level change. You can use this field to determine the formatting of this value when
Page 27 of 36
the list is printed: '* ' = Page break at group level change 'UL' = Underline at group level change (The formatting options are fixed domain values of domain SLIS_CTRLS ).
Page 28 of 36
Grid Settings
The grid setting option is available for only ALV grid type output. In the case of ALV list type output the grid setting is not applied. In order to achieve the grid settings, modify the grid setting variable of type lvc_s_glay.
*&-----------------------------------------------------------------* *& Form GRID_SETTING * *&-----------------------------------------------------------------* *& ALV Grid setting for the ALV output * *&-----------------------------------------------------------------* *& xy_grid_setting <-> Structure for grid settings * *&-----------------------------------------------------------------* FORM grid_setting CHANGING xy_grid_settings STRUCTURE lvc_s_glay. * Minimize Header section xy_grid_settings-coll_top_p = gc_true. xy_grid_settings-coll_end_l = gc_true. ENDFORM.
Grid Settings
The structure lvc_s_glay has following fields in it.
Field Name COLL_TOP_P COLL_END_L TOP_P_ONLY EOL_P_ONLY NO_COLWOPT EDT_CLL_CB Datatype CHAR CHAR CHAR CHAR CHAR CHAR Length 1 1 1 1 1 1 Description Minimize TOP_OF_PAGE Minimize END_OF_LIST Top_Of_Page only at printing END_OF_LIST only at printing ALV control: Do not optimize column width for printing ALV control: Callback when leaving an edited cell
The grid setting variable with modified settings is then passed to the import parameter i_grid_settings of Display ALV FM.
Grid Title
The grid title which is the title to be displayed on the top of the ALV output is passed to the import parameter i_grid_title of the Display ALV FM. The grid title should be of datatype char (70).
Page 29 of 36
Events in ALV
All the possible events of ALV list is obtained using FM: REUSE_ALV_EVENTS_GET. REUSE_ALV_EVENTS_GET: Returns table of possible events for a list type Import: Et_Events : The event table is returned with all possible CALLBACK events for the specified list type (column NAME). For events to be processed by the Callback, their FORM field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field FORM filled and the entry modified using constants from the type pool SLIS. Export: I_list_type: 0 = simple list 1 = hierarchical-sequential list 2 = simple block list 3 = hierarchical-sequential block list REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list. 1. It_list_commentary : Internal table with the headings of the type slis_t_listheader. This internal table has three fields: Typ : H - header, S - selection, A - action Key : only when typ is S. Info : the text to be printed
*&---------------------------------------------------------------------* *& FORM EVENTTAB_BUILD * *&---------------------------------------------------------------------* * Register for ALV Grid events * *----------------------------------------------------------------------* * <-> xyt_events ALV Events Table * *----------------------------------------------------------------------* FORM eventtab_build USING xyt_events TYPE slis_t_event. DATA: ls_event TYPE slis_alv_event. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING i_list_type =0 IMPORTING et_events = xyt_events EXCEPTIONS list_type_wrong = 1 OTHERS = 2.
Page 30 of 36
* Register Top-of-Page event. READ TABLE xyt_events WITH KEY name = slis_ev_top_of_page INTO ls_event. IF sy-subrc EQ 0. MOVE gc_top_of_page TO ls_event-form. APPEND ls_event TO xyt_events. ENDIF. "if: sy-subrc NE 0 ENDFORM. "eventtab_build
Here in this example the FM: 'REUSE_ALV_EVENTS_GET' returns all possible values and the event TOP_OP_PAGE is activated by assigning a form name TOP_OF_PAGE to the event table which of type slis_t_event. So the form with name top_of_page is mandatory as that event with corresponding name is register in event table.
*&---------------------------------------------------------------------* *& FORM COMMENT_BUILD * *&---------------------------------------------------------------------* * Build the Top-of-Page commentary for the selection criteria * *----------------------------------------------------------------------* * <-> xyt_top_of_page ALV Top-of-page Table * *----------------------------------------------------------------------* FORM comment_build USING xyt_top_of_page LIKE gt_top_of_page[]. * List Heading Lines: Type 'H' CLEAR ls_line. ls_line-typ = 'H'. * ls_line-key = "not used for this type ls_line-info = text-h45. APPEND ls_line TO xyt_top_of_page. ENDFORM. "comment_build
*&---------------------------------------------------------------------* *& FORM TOP_OF_PAGE *&---------------------------------------------------------------------* * Top-of-Page ALV Grid Event sub-routine *----------------------------------------------------------------------* FORM top_of_page. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = gt_top_of_page. ENDFORM. "top_of_page
* *
Here the text to be displayed is populated in gt_top_of_page which is of type slis_t_listheader and the passed to the FM: 'REUSE_ALV_COMMENTARY_WRITE'. The import parameters of FM: : 'REUSE_ALV_COMMENTARY_WRITE' is as follows:
FUNCTION REUSE_ALV_COMMENTARY_WRITE. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" IMPORTING
Page 31 of 36
*" VALUE(IT_LIST_COMMENTARY) TYPE SLIS_T_LISTHEADER *" REFERENCE(I_LOGO) OPTIONAL *" REFERENCE(I_END_OF_LIST_GRID) OPTIONAL *"----------------------------------------------------------------------
PF-STATUS in ALV
Setting PF-STATUS in ALV is same as any other report where the internal table excltab is used to hide and unhide the gui items. * * Hide summary button isu_mac_excltab lv_button1. UnHide DELETE excltab WHERE fcode EQ BUTTON1.
Where excltab is internal table like BEGIN OF excltab OCCURS 999, fcode LIKE regen-okcode, END OF excltab. Eg: SET PF-STATUS '0100' EXCLUDING excltab. * Set PF-Status PERFORM pf_status_set USING lt_exttab.
Where lt_extab is internal table of type slis_t_extab. Then based on the lt_exttab value the PF status can be changed.
Variants in ALV
The default variants can be created and applied to the Display ALV FM by passing the variant value (which of type disvariant) to the import parameter is_variant of Display ALV FM.
Page 32 of 36
Filter Settings
Filter settings are used to have a output criteria/selectionoptions which are applied by default. The following are the different filter options available.
fieldname type slis_fieldname, tabname type slis_tabname, seltext(40), valuf(80), valut(80), valuf_int(80), valut_int(80), sign0(1), sign_icon(4), optio(2), stype(1), decimals like dfies-decimals, intlen like dfies-intlen, convexit like dfies-convexit, edit_mask type slis_edit_mask, lowercase like dfies-lowercase, inttype like dfies-inttype, datatype like dfies-datatype, exception(1) type c, no_sign(1) type c, or(1) type c, order type order, cqvalue(5) type c, ref_fieldname like dfies-fieldname, ref_tabname like dfies-tabname, ddic_outputlen like dfies-outputlen,
which
has
certain
filter
Where gt_filter_list is of type slis_t_filter_alv. This populated internal table is then passed as the import parameter it_filter of the display ALV FM.
Page 33 of 36
Display ALV
All the above ALV settings should be passed to the standard SAP function modules REUSE_ALV in order to get the defined output. There are two different function modules REUSE_ALV_GRID_DISPLAY and REUSE_ALV_LIST_DISPLAY respectively. The import and export parameters of REUSE_ALV_GRID_DISPLAY is as follows,
function reuse_alv_grid_display. *"---------------------------------------------------------------------*"*"Globale Schnittstelle: *" IMPORTING *" REFERENCE(I_INTERFACE_CHECK) DEFAULT SPACE *" VALUE(I_BYPASSING_BUFFER) TYPE CHAR01 DEFAULT SPACE *" VALUE(I_BUFFER_ACTIVE) DEFAULT SPACE *" REFERENCE(I_CALLBACK_PROGRAM) LIKE SY-REPID DEFAULT SPACE *" REFERENCE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME DEFAULT *" SPACE *" REFERENCE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME DEFAULT *" SPACE *" REFERENCE(I_CALLBACK_TOP_OF_PAGE) TYPE SLIS_FORMNAME DEFAULT *" SPACE *" REFERENCE(I_CALLBACK_HTML_TOP_OF_PAGE) TYPE SLIS_FORMNAME *" DEFAULT SPACE *" REFERENCE(I_CALLBACK_HTML_END_OF_LIST) TYPE SLIS_FORMNAME *" DEFAULT SPACE *" REFERENCE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL *" REFERENCE(I_BACKGROUND_ID) TYPE SDYDO_KEY DEFAULT SPACE *" REFERENCE(I_GRID_TITLE) TYPE LVC_TITLE OPTIONAL *" REFERENCE(I_GRID_SETTINGS) TYPE LVC_S_GLAY OPTIONAL *" REFERENCE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL *" REFERENCE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL *" REFERENCE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL *" REFERENCE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV OPTIONAL *" REFERENCE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL *" REFERENCE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL *" REFERENCE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL *" REFERENCE(I_DEFAULT) DEFAULT 'X' *" REFERENCE(I_SAVE) DEFAULT SPACE *" REFERENCE(IS_VARIANT) LIKE DISVARIANT STRUCTURE DISVARIANT *" OPTIONAL *" REFERENCE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL *" REFERENCE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL *" REFERENCE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL *" REFERENCE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL *" REFERENCE(I_SCREEN_START_COLUMN) DEFAULT 0 *" REFERENCE(I_SCREEN_START_LINE) DEFAULT 0 *" REFERENCE(I_SCREEN_END_COLUMN) DEFAULT 0 *" REFERENCE(I_SCREEN_END_LINE) DEFAULT 0 *" REFERENCE(IT_ALV_GRAPHICS) TYPE DTC_T_TC OPTIONAL *" REFERENCE(IT_HYPERLINK) TYPE LVC_T_HYPE OPTIONAL *" REFERENCE(IT_ADD_FIELDCAT) TYPE SLIS_T_ADD_FIELDCAT OPTIONAL *" REFERENCE(IT_EXCEPT_QINFO) TYPE SLIS_T_QINFO_ALV OPTIONAL *" REFERENCE(I_HTML_HEIGHT_TOP) TYPE I OPTIONAL *" REFERENCE(I_HTML_HEIGHT_END) TYPE I OPTIONAL *" EXPORTING *" REFERENCE(E_EXIT_CAUSED_BY_CALLER)
Page 34 of 36
*" REFERENCE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER *" TABLES *" T_OUTTAB *" EXCEPTIONS *" PROGRAM_ERROR *"----------------------------------------------------------------------
Similarly, the ALV List layout is achieved using the function module, REUSE_ALV_LIST_DISPLAY.
function reuse_alv_list_display. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(I_INTERFACE_CHECK) DEFAULT SPACE *" VALUE(I_BYPASSING_BUFFER) TYPE CHAR01 OPTIONAL *" VALUE(I_BUFFER_ACTIVE) DEFAULT SPACE *" VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID DEFAULT SPACE *" VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME DEFAULT *" SPACE *" VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME DEFAULT SPACE *" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL *" VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL *" VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL *" VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL *" VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV OPTIONAL *" VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL *" VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL *" VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL *" VALUE(I_DEFAULT) DEFAULT 'X' *" VALUE(I_SAVE) DEFAULT SPACE *" VALUE(IS_VARIANT) LIKE DISVARIANT STRUCTURE DISVARIANT *" OPTIONAL *" VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL *" VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL *" VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL *" VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL *" VALUE(I_SCREEN_START_COLUMN) DEFAULT 0 *" VALUE(I_SCREEN_START_LINE) DEFAULT 0 *" VALUE(I_SCREEN_END_COLUMN) DEFAULT 0 *" VALUE(I_SCREEN_END_LINE) DEFAULT 0 *" EXPORTING *" VALUE(E_EXIT_CAUSED_BY_CALLER) *" VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER *" TABLES *" T_OUTTAB *" EXCEPTIONS *" PROGRAM_ERROR *"----------------------------------------------------------------------
Page 35 of 36
The configured settings are passed to the ALV display function module as follows
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = lv_repid i_grid_title = lv_alv_title i_grid_settings = gs_grid_settings is_layout = gs_layout it_fieldcat = gt_fcat i_default = gc_true i_save = 'A' it_sort = gt_sort_list TABLES t_outtab = gt_output_display EXCEPTIONS program_error =1 OTHERS = 2. Or CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_callback_program = lv_repid is_layout = gs_layout it_fieldcat = gt_fcat i_default = gc_true i_save = 'A' it_sort = gt_sort_list TABLES t_outtab = gt_output_display EXCEPTIONS program_error =1 OTHERS = 2.
Page 36 of 36