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 up to 90 columns in the display with the wide array of
display options.
The commonly used ALV function modules are;
1.
REUSE_ALV_LIST_DISPLAY
2.
REUSE_ALV_GRID_DISPLAY
3.
REUSE_ALV_EVENTS_GET
4.
REUSE_ALV_COMMENTARY_WRITE
5.
REUSE_ALV_FIELDCATALOG_MERGE
The different steps used for getting the above function
modules into use are described below.
Step 1: DATA DECLARATION
Sap standard type pools: SLIS.
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
TYPE-POOLS: SLIS.
* To pass name of the report in function module for ALV
Data: V_REPID LIKE SY-REPID.
* To pass the overall structure of the ALV report
Data: STRUCT_LAYOUT TYPE SLIS_LAYOUT_ALV.
* Internal table to capture various events in ALV
Data: I_EVENTS TYPE SLIS_T_EVENT.
* Table for catalog of the fields to be displayed
Data: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
Data: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
* Internal table to mention the sort sequence
Data: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
Data: X_SORT TYPE SLIS_SORTINFO_ALV.
* Internal table to display top of page
Data: i_list_top_of_page type slis_t_listheader.
* Internal table to pass data
DATA: BEGIN OF I_TAB OCCURS 0,
MATNR
LIKE MARA-MATNR,
MBRSH
LIKE MARA-MBRSH,
END OF
I_TAB.
Step2 (Defining 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).
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 of
the function module REUSE_ALV_LIST_DISPLAY or REUSE_ALV_GRID_DISPLAY.
All the values entered in the catalog are 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:
• 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 column order can be changed interactively by
the user. 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.
• 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. For fields with a Data Dictionary link this parameter can be left
initial. 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).
Initial = column width is the output length of the referred
Data Dictionary field (domain).
N = column width is n characters.
• Text The following parameters are
used for customizing the texts in the heading of the output of the columns. The
texts are taken from the Data Dictionary for fields with a Data Dictionary
reference. If this is not desired, the text parameters can also be specified.
The Data Dictionary texts are then ignored.
If the user changes the column width interactively, the
column header text with the appropriate length is always used.
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, the column width depends
on the column header.
The 'long field label' is also used in display variant
definition,
Sort, etc. Popup.
• seltext_l (long
field label)
• seltext_m (medium
field label)
• seltext_s (short
field label)
X_FIELDCAT-COL_POS = 0. * First field to appear in
ALV list
X_FIELDCAT-FIELDNAME = 'MATNR'. * Name of the field in the internal table
X_FIELDCAT-TABNAME = 'I_TAB'. * Name of the internal table
X_FIELDCAT-OUTPUTLEN =
18. * Output Length of
the field
X_FIELDCAT-SELTEXT_M = 'MatItem'. * Heading for the column
APPEND X_FIELDCAT TO I_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-COL_POS = 1.
X_FIELDCAT-FIELDNAME = 'MBRSH'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Industry Sector'.
X_FIELDCAT-OUTPUTLEN = 50.
APPEND X_FIELDCAT TO I_FIELDCAT.
CLEAR X_FIELDCAT.
2. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
Sample code for Events :
See also the documentation on IMPORTNG parameter
I_STRUCTURE_NAME.
Value range: 0, 1 - 60
Step 3(Build up events table)
The next step is to build an event table, which are used for
firing both user commands and the system dependent events.
A list of possible
events is populated into an event table (I_EVENTS) when this table is passed
from the function module REUSE_ALV_EVENT_GET. The return table from this
function module contains all the possible events.
The function module contains following import and export
parameters.
IMPORTING PARAMETERS: I_LIST_TYPE
This parameter has possible values from 0-4.
The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is
DEFAULT 0 .
EXPORTING PARAMETERS: I_EVENTS table.
This table is of TYPE SLIS_T_EVENT and returns to the
program the name of all the possible events.
The table structure contains the fields:
I_EVENTS-NAME: Name of the Callback event.
I_EVENTS-FORM: Name of the form routine that should be
called in the calling program at the event.
Only events with a form routine name are processed.
1. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
As this is a frequently-used Callback event, the form
routine can also be passed directly in the interface by passing the user
command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
Equivalent to the list processing TOP-OF-PAGE event.
3. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.
The selection information and list status are output
together (if they exist) on a separate page by default
4. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.
Analogously to TOP_OF_COVERPAGE the user can add other
information
to the information output by ALV (selection information,
list status) at this event.
5. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
If a user list status is to be set, it must be done in the
form routine assigned to this event. The ALV function codes, which must not be
active, are in the Parameter RT_EXTAB. This table must be passed with the SET
PF-STATUS command (with inactive user function codes as well, if necessary).
FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE
'USER_COMMAND'.
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE
= 0
IMPORTING
ET_EVENTS =
I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO
L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
This will prepare the events table for the report.
The report will
contain three forms for the above events:
1. FORM TOP_OF_PAGE:
This form will contain the top of page event for the report i.e. header etc
Using the function module ‘REUSE_ALV_COMMENTARY_WRITE’, the
internal table containing the headings for top of page event can be passed to
the list output. Also, any logo specific to the report can be passed to the
function module.
2. FORM USER_COMMAND: This form will contain the desired
user command i.e. pick/line selection
Step 4(Report Output list description)
A layout is build for the report output list description
USING the internal table declared above (I_LAYOUT).
Output list description structure.
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. Colwidth_optimize (1) TYPE c: This parameter optimizes
the length of the different columns in the output. The width of the different
col. now depends on the max. Length of the data in the column.
Value set: SPACE, 'X'
'X' = optimizes the column width so that all contents are
displayed completely.
2. No_colhead (1) TYPE c: This parameter suppresses the column headings
Value set: SPACE, 'X'.
'X' = column headers are not output
3. Zebra(1) TYPE c : The report is
output in the striped pattern.
Value set: SPACE, 'X'.
'X' = striped pattern (e.g. for wide lists)
4. No_sumchoice (1) TYPE c: This parameter allows the
choice for summing up Only by field catalog.
Value set: SPACE, 'X'
'X' = fields which are to be summed, passed by the calling
program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this
value interactively.
5. List_append(1) TYPE c : no call
screen. It is only useful to output block-lists without specifying the above
modules if the number of list blocks exceeds, or may exceed, the maximum number
specified in the block module documentation. These operations are not possible
for user-defined block lists.
Example code for Layouts :
I_LAYOUT-zebra = 'X'.
I_LAYOUT-colwidth_optimize = 'X'.
I_LAYOUT-key_hotspot = ‘X’.
Step 5(Deciding Sort Criteria)
The Table IT_SORT is populated with the sort criteria for
the different fields.
The caller specifies the sorting and/or subtotaling of the
basic list in the internal table IT_SORT.
This internal table has the following fields:
• spos : Sort sequence
• fieldname : Internal output table field name
• tabname : Only relevant for hierarchical-sequential lists.
Name of the internal output table.
• up : 'X' = sort in ascending order
• down : 'X' = sort in descending order
• subtot : 'X' = subtotal at group value change
• group : '* ' = new page at group value change ,'UL' =
underline at group value change
Step 6(Final Step)
The final step in the output of the report is the use of two
ALV functions modules.
1. REUSE_ALV_FIELDCATALOG_MERGE
2. 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.
FUNCTION
reuse_alv_fieldcatalog_merge.
*"---------------------------------------------------------------------
*"*"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, table, 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
The variant based on a program-internal table should only be
used for rapid prototyping since the following restrictions apply:
1. Performance is affected since the code of the table
definition must always be read and interpreted at runtime.
2. Dictionary reference are only considered if the keywords
LIKE or INCLUDE STRUCTURE (not TYPE) are used.
Step 7(Display Internal Output Table)
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
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.
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
Documentation on
function module: REUSE_ALV_GRID_DISPLAY
The function module outputs an internal table with whatever
structure in the form of a formatted single- or multi-line list.
Process:
Passing an internal table with the set of
information to be output
Passing a structure with general layout
specifications for list layout
Passing a field catalog in the form of an
internal table
The field catalog describes the fields to be output in the
list.
Notes
All interactions performed on the list refer
directly to the internal output table. Sorting the list, for example, also
involves a resorting of the internal output table passed (since it was passed
by reference).
An important factor determining the usability of
the tool or of various generic functions (totals, subtotals) is the expected
amount of data to be displayed.
Parameters :
• I_INTERFACE_CHECK
• I_BYPASSING_BUFFER
• I_BUFFER_ACTIVE
• I_CALLBACK_PROGRAM
• I_CALLBACK_PF_STATUS_SET
• I_CALLBACK_USER_COMMAND
• I_CALLBACK_TOP_OF_PAGE
• I_CALLBACK_HTML_TOP_OF_PAGE
• I_CALLBACK_HTML_END_OF_LIST
• I_STRUCTURE_NAME
• I_BACKGROUND_ID
• I_GRID_TITLE
• I_GRID_SETTINGS
• IS_LAYOUT
• IT_FIELDCAT
• IT_EXCLUDING
• IT_SPECIAL_GROUPS
• IT_SORT
• IT_FILTER
• IS_SEL_HIDE
• I_DEFAULT
• I_SAVE
• IS_VARIANT
• IT_EVENTS
• IT_EVENT_EXIT
• IS_PRINT
• IS_REPREP_ID
• I_SCREEN_START_COLUMN
• I_SCREEN_START_LINE
• I_SCREEN_END_COLUMN
• I_SCREEN_END_LINE
• IT_ALV_GRAPHICS
• IT_ADD_FIELDCAT
• IT_HYPERLINK
• E_EXIT_CAUSED_BY_CALLER
• ES_EXIT_CAUSED_BY_USER
I_CALLBACK_PROGRAM:
Name of the calling program
Program from which the function module is called and that
contains the exit routines. The program should always be a report, function
group, module pool or form routine pool (it should not be an include).
Caution: Never
pass SY-REPID directly at the interface. If field SY-REPID contains the desired
program name, you must absolutely assign this name to an auxiliary variable and
pass this variable to the interface.
I_CALLBACK_PF_STATUS_SET:
Set EXIT runtime to status
Passing an EXIT routine indicates to the ALV that the caller
wants to set a self-defined user status. As a result, the default status of the
ALV is not set. The interface of the form routine specified must be defined as
follows:
FORM set_pf_status
USING rt_extab TYPE slis_t_extab
Table RT_EXTAB contains the function codes that would be
hidden on the standard user interface.
If the caller wants to use a self-defined user interface
(for example, in order to provide additional list functions or use existing
functions), we recommend that you copy standard status STANDARD from function
group SALV and modify it accordingly. ALV standard function codes always start
with '&'.
See also the documentation on parameter
I_CALLBACK_USER_COMMAND.
If a self-defined user interface is used that includes
function codes of the standard user interface, the function codes of the
excluding table passed should be taken into account.
This means that the user status should generally be set as
follows:
SET PF-STATUS user
status EXCLUDING rt_extab.
Application functions can be added to excluding table
rt_extab if they are to be disabled.
The routine is called whenever the standard user interface
would be set with SET PF-STATUS.
I_CALLBACK_TOP_OF_PAGE
EXIT routine for handling TOP-OF-PAGE
Description
If the caller specifies an EXIT routine, this routine must
have the following form:
FORM top_of_page.
Module REUSE_ALV_COMMENTARY_WRITE can then be called within
the EXIT routine. This module is responsible for formatting the header
information and also ensures online HTML formatting. In the print preview or in
batch mode, the text passed is then output in the normal format.
If module REUSE_ALV_COMMENTARY_WRITE cannot be used, you
must use two parameters instead. In I_CALLBACK_TOP_OF_PAGE you pass the form
routine that is responsible for normal formatting in batch mode or in the print
preview mode. The form routine that is responsible for online formatting, is
passed in parameter
Note the section on
pre-defined settings.
Display options
• colwidth_optimize
Value range: SPACE, 'X'
X' = Optimizes the column width to ensure that the content
is displayed completely.
• no_colhead
Value range: SPACE, 'X'
'X' = Do not output column headings.
• zebra
Value range: SPACE, 'X'
'X' = Striped pattern (for wide lists, for example)
• no_vline
Value range: SPACE, 'X'
‘X' = Separate columns by SPACE.
You can generate the
field catalog automatically or semi-automatically by calling function module
REUSE_ALV_FIELDCATALOG_MERGE.
See also the documentation on function module :
REUSE_ALV_FIELDCATALOG_MERGE.
The minimum values required for the field catalog are
documented in the 'Default' section. The caller can optionally use all other
parameters to assign non-standard output attributes to a field.
It is only in the following cases that you are not required
to generate the field catalog and pass it explicitly:
• The structure of the internal table to be output
corresponds to a structure stored in the Data Dictionary and is referenced with
LIKE or INCLUDE STRUCTURE in the declaration of the internal table.
• All fields of this structure should be output in the list.
• The structure name is declared to the ALV using parameter
I_STRUCTURE_NAME.
Positioning
• col_pos (column
position)
Only relevant if the relative column positions should by
default not be identical to the sequence of the fields in the field catalog.
The parameter determines the relative column position of the
field in the list output. The column sequence can interactively be changed by
the user. If this parameter is set to its initial value for each field catalog
entry, the columns are arranged in the order of the fields in the field
catalog.
• fieldname (field name)
• outputlen (column
width)
Value range: 0 (initial), n
For fields with reference to the Data Dictionary you can
leave this parameter set to initial.
For fields without reference to the Data Dictionary (program
fields) you must set the parameter to the desired field output length on the
list (column width).
initial = The column width is derived from the output length
of the referenced field (domain) in the Data Dictionary.
n = The column width is n characters.
• do_sum (calculate totals for column)
Value range: SPACE, 'X'
'X' = Totals are calculated for this field of the internal
output table.
This function can also be used interactively by the user.
• no_sum (totals calculation not allowed)
Value range: SPACE, 'X'
'X' = No totals may be calculated for this field although
the data type of the field allows totalling.
Formatting column contents
The long field label is also used in the dialog boxes for
defining the display variant, the sort order, and so on.
• seltext_l (long field label)
• seltext_m (medium field label)
• seltext_s (short field label)
• reptext_ddic (heading)
Example Code
WS_REPNAME = SY-REPID.
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.
WRITE: 'SY-SUBRC: ', SY-SUBRC,
'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
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.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDIF
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.
1 Simple list output:
REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING.
* Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
*---------------------------------------------------------------------*
* Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
* Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.
2.Simple grid output:
REPORT Y_DEMO_ALV_1.
*
* Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
*---------------------------------------------------------------------*
* Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
* Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.