ALV DOCUMENTATION AND EXAMPLES11

ALV (ABAP LIST VIEWER) Sap provides a set of ALV (ABAP LIST VIEWER) function modules, which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain upto 90 columns in the display with the wide array of display options. The commonly used ALV functions used for this purpose are; 1. 2. 3. 4. 5. 6. 7. 8. 9. REUSE_ALV_VARIANT_DEFAULT_GET REUSE_ALV_VARIANT_F4 REUSE_ALV_VARIANT_EXISTENCE REUSE_ALV_EVENTS_GET REUSE_ALV_COMMENTARY_WRITE REUSE_ALV_FIELDCATALOG_MERGE REUSE_ALV_LIST_DISPLAY REUSE_ALV_GRID_DISPLAY REUSE_ALV_POPUP_TO_SELECT

The different steps used for getting the above function modules into use are : Step 1 DATA DECLARATION Sap standard type pools: SLIS , KKBLO . Sap standard tables types taken from the type pools are: SLIS_LAYOUT_ALV , SLIS_T_FIELDCAT_ALV, SLIS_T_LISTHEADER, SLIS_T_EVENT, SLIS_SELFIELD. Internal tables to be used in the program declared based on the above table types DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV, I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV, I_HEADING TYPE SLIS_T_LISTHEADER, I_EVENTS TYPE SLIS_T_EVENT. TYPES: KKBLO_SELFIELD TYPE SLIS_SELFIELD.

Step 2 (Optional)

1 of 34

ALV DOCUMENTATION AND EXAMPLES22

SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT) The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display. The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'. Sample code: CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' EXPORTING i_save = variant save condition ( A=all, U = user-specific ) CHANGING cs_variant = internal table containing the program name (and the default variant---optional ) EXCEPTIONS not_found = 2. The user can also choose from the list of existing variants using the function module ‘REUSE_ALV_VARIANT_F4’. Step 3 DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOG A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below. The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module. The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default. A field catalog need not be built-up and passed explicitly only under the following conditions: 1. The internal table to be output has the same structure as a Data Dictionary structure, which is referred to in the internal table declaration using LIKE, or INCLUDE STRUCTURE. In this case the attributes of the different fields is taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly. 2. All fields in this structure are to be output 3. The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY .

2 of 34

ALV DOCUMENTATION AND EXAMPLES33

All the values entered in the catalog is specific to the particular field whose name is entered in the fieldname FIELDNAME of the fieldcat structure. The name of the table is also entered in the corr. Fieldname TABNAME of the structure. The different possible attributes are: • Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output. Value set: 0, 1 – 3 Col_pos (column position): This parameter is relevant when the fields in the output are to be different from the sequence of the fields in the internal table used for display. The parameter specifies the relative column position of the field in the list output. The user can change the column order interactively. If this parameter is initial for all field catalog entries, columns appear in the internal table field sequence. Value set: 0, 1 – 60 Fieldname (field name): This is the name of the internal table field for which the parameters are passed in the catalog. Value set: internal output table field name (required parameter) Tabname (internal output table): Name of the internal output table that contains the field FIELDCAT-FIELDNAME above. Value set: SPACE, internal output table name. Ref_fieldname (reference field name): Name of the Data Dictionary field referred to. This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient. Value set: SPACE, Data Dictionary field name. Ref_tabname (reference table/structure field name): Structure or table name of the referred Data Dictionary field. This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field). Value set: SPACE, name of a Data Dictionary structure or table

Link to currency unit • Cfieldname (currency unit field name): This is used for currency fields that have a reference to any unit field. This is only relevant for amount columns with associated unit. This parameter contains the Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry. Value set: SPACE, output table field name • Ctabname (internal currency unit field output table): Name of the internal output table containing the FIELDCAT-CFIELDNAME field.

3 of 34

Value set: SPACE. the fields in the output internal table should not be referenced from tables in which they are key fields. The field in FIELDCAT-QFIELDNAME must have its own field catalog entry. n. Using this parameter. The user cannot change the key column sequence interactively. This parameter is most important if the output needs to contain some field. Value set: 0 (initial). Value set: SPACE. Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME. The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields. provided the fields are key fields in their referencing table. output table field name. • • • • 4 of 34 . Initial = column width is the output length of the referred Data Dictionary field (domain). the system makes some fields in the output as key fields. 'X'. they should be referenced to the tables in which they are not key fields. If the internal output table contains fields that are key fields from different tables. Parameter FIELDCAT-NO_OUT must be left initial. output table field name. Key (key column): By default. So. Value set: SPACE. Value set: SPACE. Using this parameter the Key field can be hidden interactively. Outputlen (column width): This parameter is used if the desired output length for a field is desired to be different from the internal output table field. which are not scrollable or cannot be hidden. output table field name. Instead. 'X'. 'X'.ALV DOCUMENTATION AND EXAMPLES44 Value set: SPACE. For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width). Value set: SPACE. No_out (field in field list): This parameter is used to remove certain fields from the output during initial display. 'X' = field is not displayed in the current list. • Qtabname (internal measurement unit field output table): Name of the internal output table containing the FIELDCAT-QFIELDNAME field. The user can however interactively choose the field for output from the field list in the display variant. then all those fields in the report output becomes unscrollable and cannot be hidden. incase they are not desired as key field in the output. 'X' = key field (key field output in color) and Key fields cannot be interactively hidden. fields other than key fields of the referencing table can be made key field. N = column width is n characters. For fields with a Data Dictionary link this parameter can be left initial. Key_sel (hideable key column): This parameter is only relevant for the fields which are made key fields using FIELDCAT-KEY = 'X'. Link to measurement unit • Qfieldname (measurement unit field name): Only relevant for quantity columns with unit link.

Just (justification): This parameter is used for alignment of the contents of the output table. a hand is displayed if the cursor is positioned on the field value.'1'=on). Value set: SPACE. Icon: The parameter displays certain column contents as icons. 'X'. 'L'.C: Color (coding must begin with C) . The internal output table column contents must be valid icon strings. Value set: SPACE. starting from the left. y. Fix_column (fix column): This parameter is used to fix certain columns in the output.z: '0'=off . 'X'. Value set: SPACE. No_sum (sums forbidden): No sum can be calculated over this field. Value set: SPACE. Value set: SPACE. ' ' = Default justification for this data type • • • • • • • • 5 of 34 . The fields with this parameter set cannot be output in the list nor can they be displayed interactively from the catalog. 'X'. 'X'. 'X' or 'Cxyz' (x:'1'-'9'. Do_sum (sum over column): the user can also call this function interactively. and ‘C’.Z: inverse Hotspot (column as hotspot): This parameter is used to make certain field appear as hotspot i. 'X' = column is colored with the default column highlight color.X: color number . 'X' = technical field. 'X'. Single click on such fields cause the PICK OR F2 events to happen. 'Cxyz' = column is colored with a coded color: . 'R'. Value set: SPACE. If a column without this flag is output.e. 'X' = column cells are output as hotspots. Value set: SPACE. All columns to be fixed must have this flag. This is only relevant for CHAR or NUMC fields in the output internal table. 'X' = a sum is calculated over this internal output table field. 'X' = column fixed (does not scroll horizontally). The user can change the column fixing interactively.ALV DOCUMENTATION AND EXAMPLES55 • Tech (technical field): This parameter is used to make certain field display only in the field catalog. Value set: SPACE.Y: bold . Value set: SPACE. 'X'. although the data type of the field would allow summing. only the columns to the left of this column are fixed. The justification of the column header always follows the justification of the columns. Emphasize (highlight columns in color): As name suggests. 'X' = column contents to be output as an icon. 'X' 'X' = column contents are to be output as a symbol. Symbol: The internal output table column must be a valid symbol character. Independent justification of the column header is not possible. this field parameter is used to highlight certain field with chosen colors.

the text parameters can also be specified. 'X' = value output without +/ sign. 'M'. and 'S'. The Data Dictionary texts are then ignored. 'L'. 'X' = suppress zeros. the keyword that should always be used as column header. Value set: SPACE. 'X' = output with leading zeros. It is only relevant for the value fields. the column header text with the appropriate length is always used. • • • The following parameters are used for customizing the texts in the heading of the output of the columns. 6 of 34 . The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header. If the user changes the column width interactively. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. Value set: SPACE.ALV DOCUMENTATION AND EXAMPLES66 'R' = right-justified output 'L' = left-justified output 'C' = centered output. Sample code: Suppose I_PO_DETAILS is an internal table containing two fields EBELN (PO number) and EBELP (PO item no). No_zero (suppress zeros): Only relevant for value fields. Value set: SPACE. 'X'. 'M'. etc. no attempt is made in this case to find an appropriate header for the new output width. template. Edit_mask (field formatting): To apply the report output formatting options same as in the WRITE statement in report writing. The 'long field label' is also used in display variant definition. If the column width changes. If this is not desired. Popup. No_sign (no +/. 'X'. Value set: SPACE. • Lzero (leading zeros): By default ALV outputs NUMC fields right-justified without leading zeros. Value set: SPACE. Using this parameter only the NUMC fields can be displayed with leading zeroes. Sort. and ‘S’. the column width depends on the column header. • • • • • seltext_l (long field label) seltext_m (medium field label) seltext_s (short field label) reptext_ddic(header) Analogous to the Data element main header Ddictxt (specify text) : You can specify with values 'L'.sign): This parameter is used to suppress the signs of the output fields. 'X'.

O No’. which are used for firing both user commands and the system dependent events i. EXPORTING PARAMETERS: I_EVENTS table.e. top of page. Only events with a form routine name are processed. L_FIELDCAT-SELTEXT_M = 'Item No`. 7 of 34 . field catalog “Local variable to hold the parameters for a particular field of the CLEAR L_FIELDCAT. The return table from this function module contains all the possible events. = 'Purchase order No'. I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event. end of page etc. CLEAR L_FIELDCAT Thus the catalog for the report output is prepared. I_FIELDTAB. L_FIELDCAT-KEY = 'X'. “Colored and non scrollable L_FIELDCAT-SELTEXT_S = 'Item No'. L_FIELDCAT-TABNAME = 'I_PO_DETAILS'. “The PO no is made the key field. A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. L_FIELDCAT-FIELDNAME = 'EBELN'. This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events. L_FIELDCAT-SELTEXT_L = 'PO Item No'. The function module contains following import and export parameters.ALV DOCUMENTATION AND EXAMPLES77 DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV. The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 . Step 4 The next step is to build an event table. L_FIELDCAT-TABNAME = 'I_PO_DETAILS'. “The po no becomes a hotspot = ‘P. The table structure contains the fields: I_EVENTS-NAME: Name of the Callback event. L_FIELDCAT-KEY = 'X'. L_FIELDCAT-FIELDNAME = 'EBELN'. = 'P order No'. “The po item no is made the key field. “Colored and non scrollable L_FIELDCAT-HOTSPOT L_FIELDCAT-SELTEXT_S L_FIELDCAT-SELTEXT_M L_FIELDCAT-SELTEXT_L APPEND L_FIELDCAT TO CLEAR L_FIELDCAT = 'X'. APPEND L_FIELDCAT TO I_FIELDTAB. IMPORTING PARAMETERS: I_LIST_TYPE This parameter has possible values from 0-4.

The Callback is only called if ALV has no items for a header that is to be expanded. 3.ALV DOCUMENTATION AND EXAMPLES88 The I_EVENTS table returns with the following possible constants: 1. The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. The event end-of-page is always processed in ALV and only passed to the caller via callback. RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). It is not usually used. processes a branch list which was not formatted by ALV (e. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'. In this case. RFLG_ALL is passed with 'X' if the user shows all items. it must be handled completely by the caller. 4.g.g. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user. Equivalent to the list processing TOP-OF-PAGE event. by a user action. RS_SELFIELD is initial in this case. 5. when the caller processes a details list which was not formatted by ALV (e. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.g. end-of-page cannot be formatted by ALV analogously to the basic list. a popup with additional information about the list record selected and displayed by ALV). it must be handled completely by the caller. the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND. 8. Is called at the beginning of the function module to make special settings. top-of-page cannot be formatted by ALV analogously to the basic list. The event end-ofpage still occurs in ALV. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'. The selection information and list status are output together (if they exist) on a separate page by default 7. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'. In this case. e. Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV (selection information. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.g. When ALV notices an end-of-page that was not 8 of 34 . a popup with further information about selected list records which were displayed by ALV). the form routine in FOREIGN_TOP_OF_PAGE is called. The application must ensure that entries are not repeated in the item table. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'. The event top-ofpage still occurs in ALV. This is still the case if the caller. As this is a frequently-used Callback event. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'. list status) at this event. 6. Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. This is still the case. 2. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'. 9. When ALV notices a top-of-page which was not caused by an ALV output. e.

This is only called for printing. Information output at the end of a page. FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'. LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME R_INDEX LIKE SY-TABIX R_INDEX_ITEM LIKE SY-TABIX R_INDEX_SUM LIKE SY-TABIX. MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'. 11. the form routine in FOREIGN_END_OF_PAGE is called. If the desired constant is found. The STANDARD status of the function group SALV should be used as a template for a user-specific status. READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO L_I_EVENT. Should only be used in justified cases because it costs a lot of performance. are in the Parameter RT_EXTAB. 9 of 34 . 14. 10.Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'. 12.Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'. DATA: L_I_EVENT TYPE SLIS_ALV_EVENT. If a user list status is to be set. it must be done in the form routine assigned to this event.Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'. Should only be used in justified cases because it costs a lot of performance. APPEND L_I_EVENT TO I_EVENTS. As this is a frequently used Callback event. IF SY-SUBRC = 0. 16.Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'. The ALV function codes. Sample code : FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.ALV DOCUMENTATION AND EXAMPLES99 caused by an ALV output.Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'. Information output at the end of the list 15. then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event. This table must be passed with the SET PFSTATUS command (with inactive user function codes as well. Output information before each output line. This event table (I_EVENTS) is now checked with the desired constants. its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING I_LIST_TYPE = 0 IMPORTING ET_EVENTS = I_EVENTS. which must not be active.Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'. FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'. Information output at the start of the list 13. Output information after each output line. if necessary). 17.

e pick/line selection Step 5 A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).e header etc Using the function module ‘REUSE_ALV_COMMENTARY_WRITE’. Length of the data in the column. now depends on the max. IF SY-SUBRC = 0. READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND INTO L_I_EVENT. Output list description structure. 'X' 'X' = optimizes the column width so that all contents are displayed completely. IF SY-SUBRC = 0. MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM. ENDIF. Colwidth_optimize (1) TYPE c: This parameter optimizes the length of the different columns in the output.e footer etc 3. the internal table containing the headings for top of page event can be passed to the list output. FORM USER_COMMAND : This form will contain the desired user command i. 'X'. CLEAR L_I_EVENT. This will prepare the events table for the report. 2. ENDIF.ALV DOCUMENTATION AND EXAMPLES1010 ENDIF. any logo specific to the report can be passed to the function module. FORM END_OF_PAGE : This form will contain the end of page event for the report i. APPEND L_I_EVENT TO I_EVENTS. APPEND L_I_EVENT TO I_EVENTS. 2. FORM TOP_OF_PAGE : This form will contain the top of page event for the report i. The width of the different col. Also. The parameters are described under the following heads: • Display options • Exceptions • Totals • Interaction • Detail screen • Display variants (only for hierarchical-sequential lists) • Color • Other The layout table is of type slis_layout_alv_spec and has the following fields: Display options 1. 10 of 34 . MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM. No_colhead(1) TYPE c : This parameter suppresses the column headings Value set: SPACE. Value set: SPACE. READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE INTO L_I_EVENT. The report will contain three forms for the above events: 1.

It is not relevant for block lists. Lights_fieldname TYPE slis_fieldname: Internal output table field containing the codes of exceptions to be output. 8. for wide lists) 5. If initial min_linesize is set to 80 by default. this field must also be filled for hierarchical-sequential lists. this parameter can interactively-define the maximum list width setting. Value set: SPACE. Zebra(1) TYPE c : The report is output in the striped pattern. No_min_linesize(1) TYPE c : The report line size is equal to the width of the list. Window_titlebar LIKE rsmpe-tittext: To set the titlebar on the report output. Linesize is 250. 'X' = columns separated by SPACE 6. No_hotspot(1) TYPE c : The heading of the report output are not output as hotspot. 7. Output table field code: '1' = red traffic light '2' = yellow traffic light '3' = green traffic light Fieldname for exception Value set: SPACE. It is not relevant for: hierarchical-sequential lists and multiple-line lists. 'X'. The prerequisite for this is that the parameter no_min_linesize should be ' '. Value set: 0.250 If the list is wider. Min_linesize LIKE sy-linsz: The report output contains a minimum possible length of line. Value set: SPACE.g. 11 of 34 . No_uline_hs(1) TYPE c. 'X'. internal output table field name. 'X' = striped pattern (e. 'X' = line size depends on list width ' ' = Line size is set to 80 or MIN_LINESIZE (if > 0) . Value set: SPACE. Lights_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter LIGHTS_FIELDNAME.1020 9. 'X'. the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)). No_vline(1) TYPE c : The report output contains columns only separated by space and no lines. To change this default value. 'X' = column headers are not output as hotspot 4. 10. Value set: SPACE. 'X’. . Value set: 0. Max_linesize LIKE sy-linsz: The default max. Value set: SPACE. If LIGHTS_FIELDNAME is not empty. Only relevant for hierarchical-sequential lists.ALV DOCUMENTATION AND EXAMPLES1111 'X' = column headers are not output 3. Exceptions 11. then this parameter is used to customize it. 10 . internal output table name. 80 . 12.

No_subtotals(1) TYPE c : No subtotals possible Value set: SPACE. each Subtotal that includes this record is also output with 'red traffic light'. 'X' 'X' = fields which are to be summed. Subtotals_text(60) TYPE c : Texts for subtotals Value set: SPACE. Subtotals can still be calculated and output. in totals Value set: SPACE. The user should not be able to change this value interactively. 19. Value set: SPACE. 16. provided by the calling program. if the column is wide enough. 24. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals. Numc_sum(1) TYPE c : Totals only possible for NUMC-Fields. the string 'Total' is output after the asterisks. Value set: SPACE. The fields in the subtotals are flagged DO_SUM = 'X' in the field list. Totals_only(1) TYPE c : Show only totals Value set: SPACE. Value set: SPACE.units 21. Lights_condense(1) TYPE c : If a list record is output with 'red traffic light'. passed by the calling program (FIELDCATDO_SUM = 'X'). 20. Totals_text(60) TYPE c : Text for 1st col.ALV DOCUMENTATION AND EXAMPLES1212 13. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals. If the first column is wide enough. No_unit_splitting TYPE c: No separate total lines by inh. data element name.totals_before_items TYPE c: Display totals before the items 22. The user should not be able to change this value interactively. 14. string (max.60) 12 of 34 . 18. 'X' 'X' = value whose change triggers subtotals. 'X' 'X' = no total record is to be output. 'X' 'X' = no subtotals. Lights_rollname LIKE dfies-rollname: The documentation of this data element is displayed when you call F1 help for an exception column.60) ' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up Only by fieldcatalog. 17. 'X' 'X' = only total records are output. Value set: SPACE. 23. 'String’ = The string passed is output after the total indicated by '*'. 'X' 'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level. string (max. Sums 15. Value set: SPACE.

if the column is wide enough. Box_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter BOX_FIELDNAME.: to assign the ALV standard function 'Detail' ('&ETA') to F2. => LAYOUT-F2CODE = '&ETA'. 27. Interaction 25. If the list has checkboxes at the start of records (for selecting several records). Box_fieldname TYPE slis_fieldname: Fieldname for checkbox in the report output. If the first column is not a subtotal criterion. Value set: SPACE.e. If BOX_FIELDNAME is not empty. Value set: SPACE. The user can show or hide the items by clicking on the folder symbol (hotspot). Box_rollname LIKE dd03p-rollname: rollname for checkbox 28. (Record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = 'X') 31. If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively. The field is a checkbox at the start of list records without a list header. the string 'Total' is output after the asterisks. 'X'. 'X' 'X' = all ready-for-input fields in a list are displayed as not ready-for-input. Value set: SPACE. 'X' 'X' = if one of the functions ‘Back (F03)'. Prompt when leaving Value set: SPACE. a confirmation prompt appears. function code 32. 29. F2code LIKE sy-ucomm: To assign an ALV standard function code to doubleclick (F2).ALV DOCUMENTATION AND EXAMPLES1313 ' ' = In the first column of subtotal records. 13 of 34 . if the column is wide enough. 30. 'String’ = the string passed is output after the subtotal indicated by '*'. this field must also be filled for hierarchical-sequential lists. If it is a subtotal criterion. the subtotal is indicated by an appropriate number of '*' by default. The columns defined in the field catalog as key fields (FIELDCAT-KEY = 'X') are output as hotspots. 33. i. Hotspot_fieldname TYPE slis_fieldname: Used to make the fieldname flag hotspot. this parameter contains the internal output table field name indicated by the checkbox selection column. Key_hotspot(1) TYPE c : The key fields are displayed as hotspot. if the column is wide enough and the first column is not a subtotal criterion. No_input(1) TYPE c : The fields are only display fields. clicking on a key column (highlighted in color in the list) calls the function under F2. Value set: SPACE. Confirmation_prompt: confirm. assign the function code to this parameter. internal output table name. this can be controlled via the CALLBACK event 'ITEM_DATA_EXPAND'. Ex. ‘Exit (F15)' or ‘Cancel (F12)' occurs. its value is repeated after the total. internal output table field name 26. Expand_fieldname TYPE slis_fieldname: fieldname flag ‘expand’. Value set: SPACE.

string (max. Header_text (20) TYPE c: Text for header button. setting this parameter makes ALV read the selection screen again. 'X' ' ' = Only fields whose contents are not initial are output in the detail view. and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS. These columns do not scroll horizontally.ALV DOCUMENTATION AND EXAMPLES1414 34. 'X'. 41. 'String’ = the string passed is output as the title of the detail window. No_keyfix(1) TYPE c : Used to make the key fields scrollable. 'X' = key columns not fixed 37. ' ' = The key columns defined in the field catalog by FIELDCAT-KEY = 'X' are fixed in the list output.g. 38. You can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical- 14 of 34 . Group output fields via FIELDCAT-SP_GROUP in the field list. Group_buttons(1) TYPE c : group-buttons for COL1 . Get_selinfos(1) TYPE c : To read selection screen. If the selections are read successfully. Display variants 42. 35. 'X'. a pushbutton. 40. Value set: SPACE. 'X' = list record detail display in popup (without top-of-page). Only relevant for hierarchical-sequential lists. Value set: SPACE. 'X' 'X' = the user can enter a format option for each sort criterion in the sort/subtotal popup. via which the user can call a popup which lists the report selections in a simple form. Value set: SPACE. Expand_all(1) TYPE c : Expand all positions Detailed screen 40.group_change_edit(1) TYPE c : Settings by user for new group Value set: SPACE. becomes active on the results list output by ALV.30) ` ' = ' Detail: Display' is output as the title of the detail window. for the list format when this value changes (e. 39. 36.detail_titlebar(30) type c : Titlebar for detail screen Value set: SPACE. Reprep(1) TYPE c : report report interface active. new page or underline). The item table key columns are fixed in hierarchical-sequential lists. with top-of-page.Detail_popup(1) TYPE c : show detail in popup. Value set: SPACE. If the calling program is a report with an ABAP/4 selection screen. 'X'. Detail_initial_lines(1) TYPE c : show also initial lines Value set: SPACE.COL5 . 'X' ' ' = List record detail display in full-screen mode. 'X' = initial field contents are also output in detail.No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right. Value set: SPACE. The header table key fields are not considered here. 'X'. 41.

43. This is technically a toggle between the header table and item table fields. Info_fieldname TYPE slis_fieldname: infofield for listoutput. These operations are not possible for user-defined block lists. It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds. Others 47. Value set: SPACE. 'X' = the item table fields are displayed by default in the display variant Definition Popup. Assign the name of the field containing the color code to this parameter. '1' = on) 46. internal output table field name The internal output table field must be of type CHAR(3).item_text(20) TYPE c : Text for item button. CHAR (20) = header table field pushbutton text. I_LAYOUT-no_hotspot = 'X'. CHAR (20) ' ' = The pushbutton text for the item table fields is 'Item' by default. Value set: SPACE. You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchicalsequential lists. 'X' ' ' = The header table fields are displayed by default in the display variant definition popup. I_LAYOUT-no_keyfix = 'X'. 44. The views refer to the hierarchy level of the fields.default_ item(1) TYPE c : Items as default. 15 of 34 . I_LAYOUT-colwidth_optimize = 'X'. The user can switch to the item table fields interactively. Colour 45. CHAR (20) = item table field pushbutton text. Value set: SPACE. The code must have the following syntax: 'Cxy': C = color (all codes must start with 'C') X = color number ('1'-'9') Y = bold ('0' = off. A whole list record can be colored individually using a color code in a column of the internal output table for the record. The views refer to the hierarchy level of the fields. Only relevant for hierarchicalsequential lists. I_LAYOUT-no_input = 'X'. I_LAYOUT-zebra = 'X'. Value set: SPACE. Assign the name of the field to this parameter. The user can switch to the header table fields interactively. or may exceed. This is technically a toggle between the header table and item table fields. Only relevant for hierarchicalsequential lists.ALV DOCUMENTATION AND EXAMPLES1515 sequential lists. CHAR (20) ' ' = The header table field pushbutton text is 'Header' by default. List_append(1) TYPE c : no call screen. Example code : I_LAYOUT-f2code = ws_fcode. I_LAYOUT-get_selinfos = 'X'. the maximum number specified in the block module documentation. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell.

I_LAYOUT-lights_condense = ` `.ALV DOCUMENTATION AND EXAMPLES1616 I_LAYOUT-hotspot_fieldname = FIELDNAME. 16 of 34 . I_LAYOUT-key_hotspot = ‘X’. The parameters to be passed in the IS_SEL_HIDE table are: o mode: 'R' = only the entries passed in the internal table IS_SEL_HIDET_ENTRIES Are output in the pop up. I_LAYOUT-totals_text = ` `. I_LAYOUT-detail_popup = ‘X’. The prerequisite for this is to set the parameter LAYOUT-GET_SELINFOS of the IMPORTING structure. which the list tool read in the selection screen (when called by a report with a selection screen). I_LAYOUT-GROUP_BUTTONS = ‘X’. 'S' = the selection info which the list tool read in the selection screen of the calling report are modified by the entries in the table IS_SEL_HIDET_ENTRIES. I_LAYOUT-totals_only = ` `. • t_entries-table: DDIC table names of t_entries-field. this text is taken from DDIC. I_LAYOUT-subtotals_text = ` `. • t_entries-valuf: Selection condition 'from' value (external format) • t_entries-valut: Selection condition 'to' value (external format) • t_entries-sign0: (I)nclusive (E)xclusive • t_entries-option: All values of the select options Option field allowed. They contain the selection information to be added. • If t_entries-field and t_entries-table have been entered. 'D' = do not output select option or SELNAME parameter selection info in the popup. I_LAYOUT-group_change_edit = ‘X’. I_LAYOUT-no_colhead = ‘ ‘. Selection info. I_LAYOUT-no_vline = `X’. I_LAYOUT-no_input = ‘X’. is replaced by the values passed. o t_entries-selname: (only used in t_entries-mode = 'D') : Name of the select option or parameter. • t_entries-stext: Field name in info popup. • t_entries-field: DDIC field name of the field for which selection information is to be output. o t_entries: Selection info table o t_entries-mode: 'A' = output the selection info for the current table record in the info popup. Step 6 This step is required to get the selection screen information in the report output. The following table fields are only used in t_entries-mode = 'A'.

Name of the internal output table. This internal table has the following fields: o spos : Sort sequence o fieldname : Internal output table field name o tabname : Only relevant for hierarchical-sequential lists. table. REUSE_ALV_FIELDCATALOG_MERGE 2.'UL' = underline at group value change Step 7 The final step in the output of the report is the use of two ALV functions modules. and view) I_CLIENT_NEVER_DISPL: Hide client fields default ‘X’ I_INCLNAME: Data declarations include name CHANGING parameter CT_FIELDCAT: Field catalog with field descriptions 17 of 34 . The caller specifies the sorting and/or subtotaling of the basic list in the internal table IT_SORT. REUSE_ALV_LIST_DISPLAY The first function module is used to pass the field catalog to the report output and merge it with the internal output table.ALV DOCUMENTATION AND EXAMPLES1717 Step 6 The Table IT_SORT is populated with the sort criteria for the different fields. *"--------------------------------------------------------------------*"*"Lokale Schnittstelle: *” IMPORTING *" VALUE(I_PROGRAM_NAME) LIKE SY-REPID OPTIONAL *" VALUE(I_INTERNAL_TABNAME) TYPE SLIS_TABNAME OPTIONAL *" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL *" VALUE(I_CLIENT_NEVER_DISPLAY) TYPE SLIS_CHAR_1 *" DEFAULT 'X' *" VALUE(I_INCLNAME) LIKE TRDIR-NAME OPTIONAL *" CHANGING *" VALUE(CT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV *" EXCEPTIONS *" INCONSISTENT_INTERFACE *" PROGRAM_ERROR *"--------------------------------------------------------------------Import parameters I_PROGRAM_NAME: Program in which the internal output table is declared and populated I_INTERNAL_TABNAME: Internal output table name I_STRUCTURE_NAME: Structure name (structure. o up : 'X' = sort in ascending order o down : 'X' = sort in descending order o subtot : 'X' = subtotal at group value change o group : '* ' = new page at group value change . 1. FUNCTION reuse_alv_fieldcatalog_merge.

ALV DOCUMENTATION AND EXAMPLES1818 The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply: 1. 2. Dictionary reference are only considered if the keywords LIKE or STRUCTURE (not TYPE) are used. Performance is affected since the code of the table definition must always be read and interpreted at runtime. Step 8 The other function module is used to display the internal output table with the contents FUNCTION reuse_alv_list_display. *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *” IMPORTING *" VALUE(I_INTERFACE_CHECK) 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 DEFAULT SPACE " 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 INCLUDE 18 of 34 .

ENDIF. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = WS_REPNAME I_INTERNAL_TABNAME = Internal output table field name I_INCLNAME = WS_REPNAME CHANGING CT_FIELDCAT = I_FIELDTAB. IF SY-SUBRC <> 0. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING 19 of 34 . I_CALLBACK_USER_COMMAND: EXIT routine for command handling I_STRUCTURE_NAME: Internal output table structure name IS_LAYOUT: List layout specifications IT_FIELDCAT: Field catalog with field descriptions IT_EXCLUDING: Table of inactive function codes IT_SPECIAL_GROUPS: Grouping fields for column selection IT_SORT: Sort criteria for first list display IT_FILTER: Filter criteria for first list output IS_SEL_HIDE : Selection information modification I_DEFAULT: Initial variant active/inactive logic I_SAVE: Variants can be saved IS_VARIANT : Variant information IT_EVENTS: Table of events to perform IT_EVENT_EXIT : Standard fcode exit requests table IS_PRINT: Print information IS_REPREP_ID: Initialization keys for Re/Re interface I_SCREEN_START_COLUMN: Coordinates for list in dialog box I_SCREEN_START_LINE: Coordinates for list in dialog box I_SCREEN_END_COLUMN: Coordinates for list in dialog box I_SCREEN_END_LINE: Coordinates for list in dialog box IT_EVENT_EXIT: Standard fcode exit requests table IS_PRINT: Print information IS_REPREP_ID: Initialization keys for Re/Re interface I_SCREEN_START_COLUMN: Coordinates for list in dialog box I_SCREEN_START_LINE: Coordinates for list in dialog box I_SCREEN_END_COLUMN: Coordinates for list in dialog box I_SCREEN_END_LINE: Coordinates for list in dialog box Export parameters E_EXIT_CAUSED_BY_CALLER: Delete list in CALLBACK_USER_COMMAND ES_EXIT_CAUSED_BY_USER: How the user left the list Tables T_OUTTAB: Table with data to be displayed ---mandatory Example Code WS_REPNAME = SY-REPID. WRITE: 'SY-SUBRC: '.ALV DOCUMENTATION AND EXAMPLES1919 Import parameters I_INTERFACE_CHECK: Interface consistency check log output. I_CALLBACK_PROGRAM: Name of the calling program I_CALLBACK_PF_STATUS_SET: Set EXIT routine to status. 'REUSE_ALV_FIELDCATALOG_MERGE'. SY-SUBRC.

ENDIF THIS IS THE POP UP TO ALLOW THE USER TO DYNAMICALLY SELECT THE FIELDS FOR DISPLAY HE CAN CHOOSE FROM THIS FIELDS ACC. IF SY-SUBRC <> 0. OTHER FIELDS output. TO REQUIREMENT AND HIDE THE . WRITE: 'SY-SUBRC: '. 'REUSE_ALV_LIST_DISPLAY'. SY-SUBRC.ALV DOCUMENTATION AND EXAMPLES2020 I_CALLBACK_PROGRAM = WS_REPNAME I_STRUCTURE_NAME = Internal output table field name IS_LAYOUT = I_LAYOUT IT_FIELDCAT = I_FIELDTAB I_DEFAULT = 'A' I_SAVE = 'A' IS_VARIANT = 'X' IT_EVENTS = I_EVENTS[] IT_SORT = I_SORT IS_SEL_HIDE = I_SELINFO TABLES T_OUTTAB = Internal output table field name.html THE USER HAS HIDDEN SOME OF THE FIELD FROM THE TOTAL FIELDS TO CUSTOMIZE THE REPORT OUTPUT Example report output after hiding some of the fields 20 of 34 .

html USER CAN CHOOSE A PARTICULAR SET OF FIELD FROM THE OUTPUT AND CAN SAVE IT AS VARIANTS 21 of 34 .ALV DOCUMENTATION AND EXAMPLES2121 output1.

ALV DOCUMENTATION AND EXAMPLES2222 Using other function module 'REUSE_ALV_GRID_DISPLAY’ can help us get list output in the form of a grid and also attach logos to the report output.Simple grid output: 22 of 34 . *---------------------------------------------------------------------* * Selection SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT. 2. Sample code 1 Simple list output: REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING. * Call ABAP List Viewer (ALV) CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_STRUCTURE_NAME = 'SFLIGHT' TABLES T_OUTTAB = I_SFLIGHT. * * Data to be displayed DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.

3. DATA: BEGIN OF i_outtab OCCURS 0.ALV DOCUMENTATION AND EXAMPLES2323 REPORT Y_DEMO_ALV_1. INCLUDE STRUCTURE sflight. PARAMETERS: p_title TYPE sy-title. SELECT * FROM sflight INTO TABLE i_outtab. * Call ABAP List Viewer (ALV) CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_STRUCTURE_NAME = 'SFLIGHT' TABLES T_OUTTAB = I_SFLIGHT. * I_OUTTAB TYPE SFLIGHT OCCURS 0. * * Data to be displayed DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT. DATA: w_chk TYPE c. i_selfield TYPE slis_selfield. DATA: i_private TYPE slis_data_caller_exit. "For multiple selection DATA: END OF i_outtab. TYPE-POOLS: slis. Demo for 'REUSE_ALV_POPUP_TO_SELECT' REPORT y_demo_alv_3. * START-OF-SELECTION. W_exit(1) TYPE c. *---------------------------------------------------------------------* * Selection SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT. CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' EXPORTING i_title = p_title i_selection = 'X' i_zebra = 'X' * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE =0 * I_SCREEN_END_COLUMN =0 * I_SCREEN_END_LINE =0 i_checkbox_fieldname = 'W_CHK' * I_LINEMARK_FIELDNAME = * I_SCROLL_TO_SEL_LINE = 'X' i_tabname = 'I_OUTTAB' 23 of 34 .

*internal table for data to be displayed DATA: BEGIN OF i_sflight OCCURS 0. DATA: END OF i_sflight. MESSAGE i000(0k) WITH sy-subrc. i_layout TYPE slis_layout_alv. i_print TYPE slis_print_alv. 4. * *****the internal table is modified with a cross sign for marking the ***rows selected LOOP AT i_outtab WHERE w_chk = 'X'. IF sy-subrc <> 0. lights. DATA: i_fieldcat TYPE slis_t_fieldcat_alv. i_events TYPE slis_t_event. Demo for ALV output using field catalog and layout: REPORT y_demo_alv NO STANDARD PAGE HEADING. ENDIF. * CONSTANTS: c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'. * 24 of 34 . * Includes INCLUDE <icon>. * ALV related data declaration TYPE-POOLS: slis. INCLUDE <symbol>. ENDLOOP. i_outtab-price. i_sort TYPE slis_t_sortinfo_alv.ALV DOCUMENTATION AND EXAMPLES2424 * * * * * i_structure_name = 'SFLIGHT' IT_FIELDCAT = IT_EXCLUDING = I_CALLBACK_PROGRAM = I_CALLBACK_USER_COMMAND = IS_PRIVATE = I_PRIVATE IMPORTING es_selfield = i_selfield e_exit = w_exit TABLES t_outtab = i_outtab EXCEPTIONS program_error =1 OTHERS = 2. DATA: box. i_sp_group TYPE slis_t_sp_group_alv. WRITE: / i_outtab-carrid. INCLUDE STRUCTURE sflight. * DB-Table TABLES sflight.

"Striped pattern p_nocolh AS CHECKBOX DEFAULT ' '. PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X'. * Layout of the report display SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001. "No vertical lines p_colopt AS CHECKBOX DEFAULT ' '. SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002. p_lightc AS CHECKBOX DEFAULT 'X'. p_groups AS CHECKBOX DEFAULT ' '. p_nosinf AS CHECKBOX DEFAULT ' '. p_groupb AS CHECKBOX DEFAULT ' '. "Optimizes col. DATA: i_list_top_of_page TYPE slis_t_listheader. p_sttext(60). p_totext(60). DATA: w_boxnam TYPE slis_fieldname VALUE 'BOX'. SELECT-OPTIONS s_fldate FOR sflight-fldate. SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003. SELECTION-SCREEN END OF BLOCK c. * Variant for ALV display SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000. * Parameters PARAMETERS: p_maxrow TYPE i DEFAULT 30. p_nocove AS CHECKBOX DEFAULT ' '. w_f2code LIKE sy-ucomm VALUE '&ETA'. PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' '. PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' '. SELECTION-SCREEN END OF BLOCK 0. "Key fields hot p_noinpt AS CHECKBOX DEFAULT ' '.ALV DOCUMENTATION AND EXAMPLES2525 DATA: w_repid LIKE sy-repid. SELECTION-SCREEN END OF BLOCK b. "No field for input SELECTION-SCREEN END OF BLOCK a. SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005. PARAMETERS: p_varnt LIKE disvariant-variant. p_reserv TYPE i. PARAMETERS: p_print AS CHECKBOX DEFAULT ' '. 25 of 34 . SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004. wd p_keyhot AS CHECKBOX DEFAULT ' '. p_nolinf AS CHECKBOX DEFAULT ' '. PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK d. *SELECTION-SCREEN SKIP 1. SELECTION-SCREEN END OF BLOCK e. "No column heading p_novlin AS CHECKBOX DEFAULT ' '. SELECT-OPTIONS s_connid FOR sflight-connid. p_nonewp AS CHECKBOX DEFAULT ' '. p_detpop AS CHECKBOX DEFAULT 'X'."to limit the selection SELECTION-SCREEN SKIP 1. * Report Selections SELECT-OPTIONS s_carrid FOR sflight-carrid.

Parameters 26 of 34 . * Process on value request (list of possible variants) AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt. t_sort_build USING i_sort. w_repid = sy-repid.ALV DOCUMENTATION AND EXAMPLES2626 w_lignam TYPE slis_fieldname VALUE 'LIGHTS'. Parameters PERFORM print_build USING i_print. "wg. *---------------------------------------------------------------------* INITIALIZATION. comment_build USING i_list_top_of_page. ENDIF. IF sy-subrc = 0. p_varnt = i_variant1-variant. "wg. CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' EXPORTING i_save = w_save CHANGING cs_variant = i_variant1 EXCEPTIONS not_found = 2. w_default(1) TYPE c. i_variant1 LIKE disvariant. PERFORM pai_of_selection_screen. START-OF-SELECTION. * Get default variant i_variant1 = i_variant. w_save(1) TYPE c. * PAI AT SELECTION-SCREEN. PERFORM selection. PERFORM layout_build USING i_layout. eventtab_build USING i_events. PERFORM variant_init. END-OF-SELECTION. * Set Options: save variant userspecific or general **** 'A or 'U' are for user-specific variants list **** 'X' or 'space' for general w_save = 'A'. PERFORM f4_for_variant. i_variant LIKE disvariant. sp_group_build USING i_sp_group. PERFORM PERFORM PERFORM PERFORM PERFORM fieldcat_init USING i_fieldcat. w_exit(1) TYPE c.

IF sy-subrc <> 0. ENDIF.ALV DOCUMENTATION AND EXAMPLES2727 CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = w_repid * i_internal_tabname = 'I_SFLIGHT' i_structure_name = 'SFLIGHT' i_client_never_display = 'X' i_inclname = w_repid CHANGING ct_fieldcat = i_fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error =2 OTHERS = 3. * Call ABAP/4 List Viewer CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK ='' i_callback_program = w_repid * 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 = 'SFLIGHT' i_background_id = 'ALV_BACKGROUND' * I_GRID_TITLE = * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat[] * IT_EXCLUDING = it_special_groups = i_sp_group[] it_sort = i_sort[] * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = w_save is_variant = i_variant it_events = i_events[] * IT_EVENT_EXIT = is_print = i_print * IS_REPREP_ID = * I_SCREEN_START_COLUMN =0 * I_SCREEN_START_LINE =0 * I_SCREEN_END_COLUMN =0 * I_SCREEN_END_LINE =0 * IMPORTING * E_EXIT_CAUSED_BY_CALLER = 27 of 34 . MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

can be interactively * chosen for display ls_fieldcat-no_out = 'X'. DATA: ls_fieldcat TYPE slis_fieldcat_alv.ALV DOCUMENTATION AND EXAMPLES2828 * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_sflight EXCEPTIONS program_error =1 OTHERS = 2. * CLEAR ls_fieldcat. * CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' * EXPORTING * i_callback_program = w_repid * i_structure_name = 'SFLIGHT' * is_layout = i_layout * it_fieldcat = i_fieldcat[] ** IT_EXCLUDING = * it_special_groups = i_sp_group[] * it_sort = i_sort[] ** IT_FILTER = ** IS_SEL_HIDE = ** i_default = W_DEFAULT * i_save = w_save * is_variant = i_variant * it_events = i_events[] ** IT_EVENT_EXIT = * is_print = i_print ** I_SCREEN_START_COLUMN = 0 ** I_SCREEN_START_LINE =0 ** I_SCREEN_END_COLUMN =0 ** I_SCREEN_END_LINE =0 ** IMPORTING ** E_EXIT_CAUSED_BY_CALLER = * TABLES * t_outtab = i_sflight. ENDIF. *The field is not displayed in the initial output. ls_fieldcat-fieldname = 'SEATSOCC'. IF sy-subrc <> 0. *---------------------------------------------------------------------* * FORM FIELDCAT_INIT * *---------------------------------------------------------------------* * --> L_FIELDCAT * *---------------------------------------------------------------------* FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. key 'A' and can be *displayed using the special group buttons 28 of 34 . *This field is assigned to a special group with tech.

* CLEAR ls_fieldcat. APPEND ls_fieldcat TO l_fieldcat. ls_fieldcat-fieldname = 'PRICE'. ELSE. *The field cannot be summed irrespective of its data type ls_fieldcat-no_sum = 'X'. ls_fieldcat-fieldname = 'SEATSMAX'. ls_fieldcat-fieldname = 'CARRID'. l_sflight-box = 'X'. l_sflight-lights = '3'. ENDLOOP. l_sflight-lights = '1'. ENDFORM. * CLEAR ls_fieldcat. *---------------------------------------------------------------------* * FORM DATA_ADD * *---------------------------------------------------------------------* * --> L_SFLIGHT *---------------------------------------------------------------------* FORM data_add TABLES l_sflight STRUCTURE i_sflight. ls_fieldcat-no_out = 'X'. ls_fieldcat-sp_group = 'A'. * CLEAR ls_fieldcat. APPEND ls_fieldcat TO l_fieldcat. ELSE. l_sflight-lights = '2'. APPEND ls_fieldcat TO l_fieldcat. ls_fieldcat-outputlen = 7. LOOP AT l_sflight. ENDFORM. IF sy-tabix > 10. *---------------------------------------------------------------------* * FORM EVENTTAB_BUILD *---------------------------------------------------------------------* * --> l_EVENTS * * 29 of 34 . ENDIF. ls_fieldcat-sp_group = 'B'. APPEND ls_fieldcat TO l_fieldcat. MODIFY l_sflight.ALV DOCUMENTATION AND EXAMPLES2929 ls_fieldcat-sp_group = 'A'. IF sy-tabix = 1. ENDIF. ls_fieldcat-no_out = 'X'.

ENDIF. IF sy-subrc = 0. ENDFORM. READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event. MOVE c_formname_top_of_page TO ls_event-form. * CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING i_list_type = 0 IMPORTING et_events = l_events. APPEND ls_line TO l_top_of_page. DATA: ls_event TYPE slis_alv_event. APPEND ls_event TO l_events. ls_line-typ = 'S'. * LS_LINE-KEY: not used for this type Ls_line-info = 'Status list'. APPEND ls_line TO l_top_of_page. ls_line-key = 'Key 1'. *---------------------------------------------------------------------* * FORM COMMENT_BUILD * *---------------------------------------------------------------------* * --> L_TOP_OF_PAGE * *---------------------------------------------------------------------* FORM comment_build USING l_top_of_page TYPE slis_t_listheader. APPEND ls_line TO l_top_of_page. DATA: ls_line TYPE slis_listheader. ls_line-info = 'Information'. ENDFORM. APPEND ls_line TO l_top_of_page. ls_line-key = 'Key 2'. ***Selection CLEAR ls_line. ***Action CLEAR ls_line. * LS_LINE-KEY: not used for this type ls_line-info = 'Heading list'. ls_line-typ = 'A'. 30 of 34 . ***Header CLEAR ls_line. ls_line-typ = 'H'.ALV DOCUMENTATION AND EXAMPLES3030 *---------------------------------------------------------------------* FORM eventtab_build USING l_events TYPE slis_t_event.

ls_layout-f2code = w_f2code. ls_layout-box_fieldname = space. ls_layout-detail_popup = p_detpop. IF p_lights = 'X' OR p_lightc = 'X'.ALV DOCUMENTATION AND EXAMPLES3131 *---------------------------------------------------------------------* * FORM LAYOUT_BUILD * *---------------------------------------------------------------------* * <-> LS_LAYOUT * *---------------------------------------------------------------------* FORM layout_build USING ls_layout TYPE slis_layout_alv. IF p_chkbox = 'X'. ls_layout-no_vline = p_novlin. ENDFORM. CLEAR ls_sp_group. * E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB. ls_layout-subtotals_text = p_sttext. ls_sp_group-sp_group = 'B'. ls_layout-no_input = p_noinpt. ls_layout-totals_only = p_totonl. ls_layout-totals_text = p_totext. ls_layout-colwidth_optimize = p_colopt. ls_layout-no_colhead = p_nocolh. ENDIF. * ls_layout-group_buttons = 'X'. *Fieldname for check box on the report output ls_layout-box_fieldname = w_boxnam. ls_sp_group-text = 'Reservation status'. ls_layout-key_hotspot = p_keyhot. ELSE. *Fields are assigned to the special group CLEAR ls_sp_group. APPEND ls_sp_group TO l_sp_group. ls_layout-lights_condense = p_lightc. DATA: ls_sp_group TYPE slis_sp_group_alv. ENDIF. **Fieldname for lights on the report output ls_layout-lights_fieldname = w_lignam. ls_sp_group-sp_group = 'A'. *---------------------------------------------------------------------* * FORM SP_GROUP_BUILD * *---------------------------------------------------------------------* * --> L_SP_GROUP * *---------------------------------------------------------------------* FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv. ls_layout-group_change_edit = p_groups. ls_layout-zebra = p_zebra. CLEAR ls_layout-lights_fieldname. ELSE. 31 of 34 .

ELSE. PERFORM data_add TABLES i_sflight... MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. * CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING i_logo = 'ENJOYSAP_LOGO' it_list_commentary = i_list_top_of_page.. ENDFORM.ALV DOCUMENTATION AND EXAMPLES3232 ls_sp_group-text = 'Flight charges'. APPEND ls_sp_group TO l_sp_group. ENDFORM. p_varnt = i_variant1-variant... SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight UP TO p_maxrow ROWS WHERE carrid IN s_carrid AND connid IN s_connid AND fldate IN s_fldate. ENDFORM. *---------------------------------------------------------------------* * FORM TOP_OF_PAGE *---------------------------------------------------------------------* * .. IF sy-subrc = 2. ENDIF. * *---------------------------------------------------------------------* FORM top_of_page. *---------------------------------------------------------------------* * FORM SELECTION * *---------------------------------------------------------------------* FORM selection. * CALL FUNCTION 'REUSE_ALV_VARIANT_F4' EXPORTING is_variant = i_variant i_save = w_save * it_default_fieldcat = IMPORTING e_exit = w_exit es_variant = i_variant1 EXCEPTIONS not_found = 2.. *---------------------------------------------------------------------* * FORM F4_FOR_VARIANT * *---------------------------------------------------------------------* FORM f4_for_variant. ENDIF. IF w_exit = space. * 32 of 34 .

. * IF NOT p_varnt IS INITIAL. *&---------------------------------------------------------------------* *& Form PAI_OF_SELECTION_SCREEN *&---------------------------------------------------------------------* * to check whether right variant is entered on the selection scr *----------------------------------------------------------------------* FORM pai_of_selection_screen. " VARIANT_INIT *---------------------------------------------------------------------* * FORM PRINT_BUILD * *---------------------------------------------------------------------* * . l_print-print = p_print. *---------------------------------------------------------------------* 33 of 34 .. i_variant-report = w_repid. ENDFORM. l_print-no_new_page = p_nonewp. l_print-no_print_selinfos = p_nosinf. ELSE.. MOVE i_variant TO i_variant1. ENDFORM. MOVE p_varnt TO i_variant1-variant. * CLEAR i_variant.. " PAI_OF_SELECTION_SCREEN *&---------------------------------------------------------------------* *& Form VARIANT_INIT *----------------------------------------------------------------------* FORM variant_init. i_variant = i_variant1. l_print-no_print_listinfos = p_nolinf.. l_print-reserve_lines = p_reserv. * *---------------------------------------------------------------------* FORM print_build USING l_print TYPE slis_print_alv. l_print-no_coverpage = p_nocove. PERFORM variant_init. CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE' EXPORTING i_save = w_save CHANGING cs_variant = i_variant1. * l_print-print = p_print. ENDFORM.ALV DOCUMENTATION AND EXAMPLES3333 ENDFORM.. ENDIF..

ls_sort-fieldname = 'CARRID'.ALV DOCUMENTATION AND EXAMPLES3434 * FORM T_SORT_BUILD * *---------------------------------------------------------------------* FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv. ls_sort-up = 'X'. 34 of 34 . DATA: ls_sort TYPE slis_sortinfo_alv. ENDFORM. APPEND ls_sort TO l_sort. ls_sort-subtot = 'X'. ls_sort-spos = 1.

Sign up to vote on this title
UsefulNot useful