Professional Documents
Culture Documents
06/2004
Contents
- What is the ALV - Using the ALV - Programming the ALV
The Field Catalog The Is_Layout structure (grid characteristics) Starting the ALV with sorting and subtotals Controlling the users ability to create layouts Implementing a custom GUI Status Responding to drilldown and custom functions Creating headers and footers using events
2
Export to Word
Sort
Change layout
The report will be sorted by vendor name (asc) then year (desc) and subtotaled by vendor name
The next screen displayed allows you to enter the filtering criteria
ALV Control
Give you more flexibility (multiple controls per screen, drag & drop) You need some understanding of dialog programming and objects
Code that you may see using the function modules CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_structure_name = CHANGING ct_fieldcat = CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = TABLES t_outtab =
Code that you may see with controls Data: g_custom_container type ref to cl_gui_custom_container, Grid type ref to cl_gui_alv_grid Create object g_custom_container Exporting Container_name = CCCONTAINER. Create object grid Exporting i_parent = g_custom_container. Call method grid->set_table_for_first_display exporting i_structure_name = changing it_outtab =
9
it_fieldcat
TABLES t_outtab EXCEPTIONS program_error OTHERS
= t_fieldcat
= t_data = 1 = 2.
IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
10
The TYPEs used in the ALV function modules are defined in TYPE-POOL SLIS
Example code to define the field catalog:
TYPE-POOLS: slis.
DATA: s_fieldcat TYPE slis_fieldcat_alv, t_fieldcat TYPE slis_t_fieldcat_alv.
11
12
13
Edit
Will allow the user to change the values within the ALV and those chages are reflected in the internal table in the calling program.
15
Fields in IT_SORT
Spos Fieldname Up Down Subtot Expa Sort order Field to sort Values: space, X Values: space, X Values: space, X If X will show only subtotals
Sample code
s_sort-fieldname = 'NAME1'. s_sort-up = 'X'. s_sort-subtot = 'X'. append s_sort to t_sort. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = t_fieldcat IT_SORT = t_sort TABLES T_OUTTAB = t_data.
16
Sample code
Data: g_save(1) type c.
If sy-uname in poweruser_group.
g_save = A. Else. g_save = U. Endif. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = g_repid 'SET_PF_STATUS' it_fieldcat i_save TABLES t_outtab = t_data.
17
U A
If you are not going to support all of these functions or need to add custom functions, you need to create and implement your own GUI status.
18
1. Press the copy status button 2. Fill in this screen and press the copy button
19
You may also want to add your own custom functions to it.
20
To have the ALV invoke this routine, set i_callback_program to your program name and i_callback_pf_status_set to the name of the new subroutine.
The subroutine name can be any valid name although make sure it is all capitalized in the call function statement.
***************************************************** form alv_pf_status using rt_extab type slis_t_extab. ***************************************************** <you may want to manipulate rt_extab here> set pf-status 'STANDARD excluding rt_extab. endform.
21
22
Sumindex
rs_selfield-value.
Col_stable
Row_stable
Exit
Use function module REUSE_ALV_EVENTS_GET to return an internal table of all events available in the ALV.
USER_COMMAND
ALV_TOP_OF_PAGE PF_STATUS_SET
This list is in a structure that consists of TOP_OF_PAGE 2 fields; an event name and a form name
Find the event in the table that you want to invoke and update the form name with TOP_OF_LIST the name of the subroutine in your END_OF_PAGE program. *** You cannot use write statements to produce headers and footers. You must use function module REUSE_ALV_COMMENTARY_WRITE. Please see documentation for details.
END_OF_LIST
25
26
Contact information:
27