ALV Reports Using FM
ALV Reports Using FM
Type-Pool Declaration
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
Before calling the ALV function module, type pools declaration is mandatory. Syntax Type-pools: SLIS. Note: slis_t_fieldcat_alv contains "_t_. It means that it is an internal table and slis_fieldcat_alv is header line of that.
1.) Using FM REUSE_ALV_FIELDCATALOG_MERGE. Exporting: IT_FIELDCAT - field catalog Internal Table. Declare a data dictionary structure containing fields to be displayed in the output. Call the FM and pass the structure name to the FM. The FM automatically populates the fieldcatalog internal table.
ALV Layout
Use: Populate Layout Features for ALV output. Data Declaration: For field catalog population, declare a structure of type SLIS_LAYOUT_ALV.
Exporting: IS_LAYOUT: ALV layout structure. Fields of the layout structure: COLWIDTH_OPTIMIZE optimizes the column width. Pass X to activate. ZEBRA ALV layout will be displayed in a zebra color format. Pass X to activate. NO_SUBTOTALS subtotals will not be displayed. Pass X to activate. NO_TOTALLINE the grand total line will not be displayed. Pass X to activate.
ENDFORM.
ALV Sorting
Use:
Identify the fields on which sorting needs to be performed. Subtotaling is also performed here. For sort table population, declare a internal table of type SLIS_T_SORTINFO_ALV.
Data Declaration:
Exporting IT_SORT: internal table for Sorting. Fields of the sort structure: - FIELDNAME : field name on which sort is required. - SPOS : sort priority, pass incremental numbers example: 1, 2, 3 etc. - UP : pass X to sort in ascending order. - DOWN : pass X to sort in descending order. - SUBTOT : pass X to get the subtotal for every break of the sort.
REUSE_ALV_GRID_DISPLAY FM to display ALV Grid Output. The following are the important parameters:
Exporting
: report id : report layout. : field catalog populate the field names, column description, column width etc. : sorts the ALV list populate the field on which sort is required. : populate the events to be triggered along with the subroutine names.
Tables
T_OUTTAB
Use: Populate the text to be displayed on top of the page. Data Declaration: Declare a structure of type SLIS_LISTHEADER and an internal table of type SLIS_T_LISTHEADER. Parameter: I_CALLBACK_TOP_OF_PAGE Fields of the list header structure. - INFO : field to be displayed. - TYP : type of display of text. Example values are H,S and A - KEY : text to be displayed in front of the field. Call the FM REUSE_ALV_COMMENTARY_WRITE in the subroutine and pass the internal table to it.
Use To define user interaction on specific fields and their individual behavior. Parameter: I_CALLBACK_USER_COMMAND Syntax: FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. The parameter R_UCOMM contains the function code. The structure RS_SELFIELD has the details about the current cursor position.
Use: To add application toolbar buttons and their functions. Syntax: FORM set_pf_status USING rt_extab TYPE slis_t_extab. ENDFORM. Parameter: I_CALLBACK_PF_STATUS_SET
Custom buttons on Application Toolbar: Copy the PF status STANDARD of program SAPLKKBL to the user defined PF status of the current program. Now the buttons can be added to the custom PF status.
FORM pf_status_set USING rt_extab TYPE slis_t_extab. set pf-status 'ZSTANDARD'. ENDFORM.
Define a field of type CHAR1 in the data internal table and subsequently the field catalog table. Fill the layout properties of ALV as follows: Is_layout-box_fieldname = <field_name> Ex: Define field FLAG of type CHAR1 as first field of data internal table. ls_layout-box_fieldname = FLAG. Pass the parameter Is_layout to the function module REUSE_ALV_GRID_DISPLAY
Block List Display uses the Function Module REUSE_ALV_BLOCK_LIST_DISPLAY. Sample Code: DATA ls_print TYPE slis_print_alv.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY' EXPORTING i_interface_check = ' ' is_print = ls_print. Sample Program: Z31_SAMP
Hierarchical list display uses the function module REUSE_ALV_HIERSEQ_LIST_DISPLAY. Syntax: Call function Reuse_ALV_Hierseq_List_Display Exporting I_Tabname_Header = (pass header table name) I_Tabname_Item = (pass item table name) Tables T_Outtab_Header = (pass the header internal table) T_Outtab_Item = (pass the item internal table)