Upload
mkpatil
View
20
Download
1
Embed Size (px)
DESCRIPTION
Citation preview
Lecture 15ALV Grid Control
BCO5647 Applications Programming Techniques (ABAP)
2BCO5647
Readings & Objectives
Readings
An Easy Reference for ALV Grid Control (PDF file on WebCT)
Objectives
This lecture will
Outline the history of the List Viewer in SAP
Introduce the basic features of the List Viewer
Review ABAP Objects in preparation to using ALV Grid
Introduce the features of ALV Grid Control
Explain how to build a ALV Grid Control application
3BCO5647
Key Outcomes
To use standard functions in your program that are encapsulated in global classes.
To learn some basic object-oriented syntax elements of ABAP Objects using the SAP List Viewer as an example. In this context, references to instances of the standard classes CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID are created. The instance of the SAP List Viewer calls the method SET_TABLE_FOR_FIRST_DISPLAY to display a formatted internal table in the SAP List Viewer.
4BCO5647
Working with Methods
Classes and Objects
5BCO5647
Creating Objects and Calling Methods
6BCO5647
Application Example: ALV Grid Control
7BCO5647
Program with ALV Grid Control
8BCO5647
Objects and Classes for ALV Grid Control
To call the custom container controls and the ALV Grid Control, the following global classes (object types) are available in the Class Builder:
CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID
9BCO5647
ALV Grid Control: Important Methods
The global class CL_GUI_ALV_GRID contains a large number of methods. To display the contents of an internal table with an ALV Grid Control, all you need to do is to use the following three methods:
CONSTRUCTOR - the pointer to the container control instance must be passed to the constructor (not used in next example).
SET_TABLE_FOR_FIRST_DISPLAY - the internal table with the data to be displayed must be passed to the parameter IT_OUTTAB. This must be a standard table so that the user can make use of the sort functions. Furthermore, technical information is required for editing the grid columns. The easiest approach is to use a flat structure or a transparent table, that is, a global type such as the line type for the internal table. In this case, you need only pass the name of this line type to the I_STRUCTURE_NAME parameter.
REFRESH_TABLE_DISPLAY - you only need to call this method if you have changed the contents of the internal table after the first display.
10BCO5647
Display the contents of an internal table on a Screen with ALV Grid Control
REPORT sapmz_hf_alv_grid .TABLES: sflight.*--------------------------------------------------* G L O B A L I N T E R N A L T A B L E S*--------------------------------------------------DATA: gi_sflight TYPE TABLE OF sflight.*--------------------------------------------------* G L O B A L D A T A*--------------------------------------------------DATA: g_wa_sflight LIKE sflight.* Declare reference variables to the ALV grid and the containerDATA: go_grid TYPE REF TO cl_gui_alv_grid, go_custom_container
TYPE REF TO cl_gui_custom_container.START-OF-SELECTION. SET SCREEN '101'.*&------------------------------------------------**& Module USER_COMMAND_0101 INPUT*&------------------------------------------------* MODULE user_command_0101 INPUT. CASE sy-ucomm. WHEN 'EXIT'. LEAVE TO SCREEN 0. ENDCASE. ENDMODULE. " USER_COMMAND_0101 INPUT
11BCO5647
Display the contents of an internal table on a Screen with ALV Grid Control
*& Module STATUS_0101 OUTPUT*&------------------------------------------------* MODULE status_0101 OUTPUT. set pf-status 'GRID'.* Create objects IF go_custom_container IS INITIAL. CREATE OBJECT go_custom_container EXPORTING container_name = 'CONTAINER_1'. CREATE OBJECT go_grid EXPORTING i_parent = go_custom_container. PERFORM load_data_into_grid. ENDIF. ENDMODULE. " STATUS_0101 OUTPUT*&------------------------------------------------**& Form load_data_into_grid*&------------------------------------------------* FORM load_data_into_grid.* Read data from table SFLIGHT SELECT * FROM sflight INTO TABLE gi_sflight.* Load data into the grid and display them CALL METHOD go_grid->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = gi_sflight. ENDFORM. " load_data_into_grid