0

ALV Grid Control

Contents:
 Features  Constructor, methods and events  Data descriptions

© SAP AG 1999

(C) SAP AG

BC412

5-1

0.2
ALV Grid Control: Unit Objectives

At the conclusion of this unit, you will be able to:  Describe the features of the ALV Grid Control  Display list data in the ALV Grid Control  Read and change properties of the ALV Grid Control  Format print lists with the ALV Grid Control  Generate a field catalog

© SAP AG 1999

(C) SAP AG

BC412

5-2

0.3
Course Overview Diagram BC412

Unit 1

Course Overview

Unit 2

Introduction to the Control Framework

Unit 3

SAP Container

Unit 4

SAP Tree Control

Unit 5

ALV Grid Control

© SAP AG 1999

(C) SAP AG

BC412

5-3

0.4 ALV Grid Control Overview: Features Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-4 .

5 ALV Grid Control Properties  Display of nonhierarchical lists Typical list functions: Air.    (C) SAP AG BC412 5-5 .Find .Report-Report .Totals/subtotals Numerous interfaces: . they can swap columns. you can adjust these implementations to meet application-specific needs. calculate totals.. These functions are implemented in the proxy object class.0. However. In most cases the implementations of the standard functions provided by the control are sufficient. print preview.69 USD AA 17 2000-02-20 513.. filter. the associated list is always displayed based on the settings of this variant. If a display variant is set as the default variant.00 USD AA 400 2000-01-13 1234. send list. Flight.56 DEM LH 402 2000-05-28 1234. The settings (list customizing) made by a specific user are called a display variant. export list (in different formats)..69 USD AA 64 2000-05-19 369.. set filters for the data to be displayed.56 DEM LH . The ALV Grid Control allows users to adjust the layout of lists to meet their individual requirements (for example.Excel/Word . Display variants can be saved on a user-specific or on a global basis.. You can add self-defined functions to the toolbar. You as the programmer have the possibility to turn off functions not needed. print.69 USD AA 17 2000-03-11 513.. and so on. if necessary.Sort . Date Curr.Filter .56 DEM LH 400 2000-02-16 1234. The ALV Grid Control offers a range of interactive standard list functions that users need frequently (find. .Mail . and so on). The list data is displayed as a table on the screen. if required.File.56 DEM LH 400 2000-03-21 1234. sort. they can be offered to the user for selection. Price 17 2000-01-17 513. If such display variants exist for a list. hide columns. calculate totals and subtotals.56 DEM LH 400 2000-03-04 1234.User-specific and / or global save mode © SAP AG 1999  The ALV Grid Control is a tool with which you can output non-hierarchical lists in a standardized format. Display variants supported ..

 Subtotal: This function is analogous to Total.6 Standard Pushbuttons Display list row details in a dialog box Sort in ascending order (by columns selected) Sort in descending order (by columns selected) Find items in the list Set filter: determine data to be displayed based on a condition (row selection) Calculate totals for selected columns Subtotals Print. (C) SAP AG BC412 5-6 .  Find: You can determine a search term and the search order (columns or rows). select. . Local file. the system displays the content of all list fields (including hidden columns) in a modal list window.  Sort in ascending order: Select one or more columns. the system displays a dialog box on which you can select the column (sort order depends on the order of the columns selected).0. Office and ABC Analysis. If you choose Details. and so on © SAP AG 1999  The control toolbar provides the following standard functions:  Details: Select a row on the list.. If you choose Sort in ascending order. The sort order is determined by the display order of the columns on the screen. save variants. change.  Set filter: You can determine the amount of data displayed by defining value selections (SELECTOPTIONs) for each column (column selection: see Sort in ascending order). Word processing. Display variants: customize column selection. (Note: You can only display subtotals if totals are calculated). If you do not select a column beforehand. send. local file. word-processing.  Sort in descending order: This function is analogous to Sort in ascending order. print preview Transfer data --> spreadsheet. Send. the system sorts the list content by the columns selected.  Total: The system calculates totals for the columns selected..  Print: The options available are Print (print dialog ->Print) and Print preview.  Export: The options available are Spreadsheet.

and Manage display variant. (C) SAP AG BC412 5-7 . Change display variant. Display variants: The functions available are Choose display variant.

7 Features Overview: Technical View Features Features Technical view Technical view Screen and print list Screen and print list Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-8 .0.

ALV Grid Control chain takes place interactively at runtime.0. From a technical point of view. The spool system is used for the output of the associated ABAP print lists. the "wrapper" (cl_gui_alv_grid) does more than encapsulate the dialog with the frontend control. The standard functions provided for screen output and the creation of the ABAP print list are implemented in proxy class cl_gui_alv_grid. The proxy class is an "application wrap" around the technical "wrapper" of the control communication.proxy object .     (C) SAP AG BC412 5-9 . ALV proxy objects maintain only a minimum amount of information on the data to be displayed.8 ALV Grid Control: Technical View ALV Grid Control Frontend Printer/spool Application server ALV proxy object ABAP program List data Field catalog Additional info © SAP AG 1999  The class cl_gui_alv_grid encapsulates the technical details of the communication with the frontend control of the ALV Grid Control. since the proxy objects communicate with three partners:  Frontend Grid Control: Display of the list data as a table  ABAP program: User  Spool system / printer: Output of the list data as an ABAP print list Communication through the ABAP program . The data to be displayed and the rules according to which the data is to be displayed (field catalog) must be held in the program in global data objects.

(C) SAP AG BC412 5-10 .9 ALV Grid Control: List Data ALV Grid Control Frontend Printer/spool Application server ALV proxy object ABAP program List data Field catalog Additional info © SAP AG 1999  Data that is to be output on the screen or as an ABAP print list is called list data.0.

10 Creating List Data and Holding Data ALV Grid Control Printer/spool ALV proxy object Proxy object holds only a pointer to the data object ABAP program Internal table Internal table must be a global data object in the program or a class or object attribute Sorting (using Grid Control button) is applied to the program data Read access for all other standard functions of the ALV Grid Control List data © SAP AG 1999  To display the data in the ALV Grid Control (or print the data using the control). The proxy object does not have a copy of the data.    (C) SAP AG BC412 5-11 .0. the proxy object performs all interactive actions in the frontend control (sort. Sort processes in the ALV Grid Control change the state of the internal table in the calling program. the internal table that contains the list data must be declared as global in the program (or as a static variable in a class). all other actions perform only read access to the data. To improve performance. filter. but maintains a reference to the internal table passed. you must pass the data in an internal table to the proxy object. For this reason. and so on) on the internal table in the calling program.

0. (C) SAP AG BC412 5-12 .11 ALV Grid Control: The Field Catalog ALV Grid Control Frontend Printer/spool Application server ALV proxy object ABAP program List data Field catalog Additional info © SAP AG 1999  The field catalog is dealt with in more detail in the following.

.. For each column of the data table. You use another internal table to pass this information to the proxy object. . . . . . .. . So that the proxy object can properly format the data passed during screen output or creation of the print list.. carrid connid fldate .   (C) SAP AG BC412 5-13 . the object needs information on how the columns of the internal table are to be presented (properties of the fields of the internal table row type). 20000312 . This internal table is called the field catalog. . Properties of column carrid Properties of column connid Properties of column fldate Properties of column . For row types defined in the ABAP Dictionary. .. see the section The Field Catalog of this unit. Field catalog: column properties 20001010 ..0. the field catalog must contain a row that determines the technical properties and additional formatting information of the column. you must use different procedures referred to as Semi-Automatically Generated Field Catalog or Manually Generated Field Catalog. . the field catalog can be generated differently. The proxy object copies all properties of the fields of the Dictionary structure and generates the field catalog automatically. . © SAP AG 1999  The internal table with the data to be displayed that was passed to the proxy object can have any row type which can be chosen as required.. If you use other row types. you need only pass the name of the structure in the ABAP Dictionary to the proxy object. For more details... This is the most common procedure and is called Automatically generated field catalog. Depending on the row type of the data table..12 Functions of the Field Catalog ALV Grid Control / print list er op Pr Co nt en t s t ie Internal table itab with data carrid connid fldate AA AZ LH QA 0603 1702 0400 . 20000105 .

0. new for Release 4.6)... Table type LVC_T_FCAT uses the global row type LVC_S_FCAT.  (C) SAP AG BC412 5-14 . defined in the ABAP Dictionary.13 Data Descriptions: The Field Catalog LVC_T_FCAT Table type in the ABAP Dictionary for the field catalog LVC_S_FCAT Row type in the ABAP Dictionary Structure Properties of column 1 Properties of column 2 Properties of column 3 . Internal table with column/ field properties © SAP AG 1999  Internal tables that contain field catalogs must be typed with reference to table type LVC_T_FCAT (type of an internal table.

0... .)  Formatting of the column contents (decimal place formatting. see the section on the field catalog © SAP AG 1999  Row type LVC_S_FCAT contains the following information:  Column indicator (names of the fields. names of the reference fields in the ABAP Dictionary.14 Information in the Field Catalog (Structure) LVC_S_FCAT Structure type in the ABAP Dictionary for the field catalog Column indicator Unit-specific formatting Output properties of columns Formatting of column contents Texts Technical column properties Other fields For details.)  Formatting options for currency and quantity fields  Output properties of the columns (order..)  Texts for column headers... detail screens and output in hotspot format  Technical column properties  Other fields For more detailed information. .  (C) SAP AG BC412 5-15 . see the section The field catalog of this unit.. .

you can pass additional information to the proxy object. (C) SAP AG BC412 5-16 .15 ALV Grid Control: Additional Information ALV Grid Control Frontend Printer/spool Application server ALV proxy object ABAP program List data Field catalog Additional info © SAP AG 1999  In addition to the list data and the field catalog.0.

0.16
ALV Grid Control: Function of Additional Information

Additional info
Control layout info Print list layout info

 Formatting information for data output
(data-independent)

Data info

Rules for data output
(data-dependent)

© SAP AG 1999

The additional information comprises:  Layout information For the frontend control For the print list  Information that contains the display rules for the data to be output Sort criteria Filter criteria Texts for field groups

(C) SAP AG

BC412

5-17

0.17
Function of Additional Information in Detail
ALV Grid Control

Printer/spool

ALV proxy object

ABAP program Data area (grid) Toolbar Print list

Layout info

Sort

Filter

Field groups Data info

© SAP AG 1999

You can use the following data object types to pass additional information to the ALV proxy object:  Layout of the frontend control: Settings for the data area are passed using a structure. You can use an internal table to control the composition of the toolbar.  Layout of the print list: You can use the fields of a structure to control parts of the list layout.  You use internal tables to pass information about sort criteria, filter options, and field group texts to the proxy object.

Normally, you do not set up filter and sort criteria manually since they can be changed interactively by the user. The proxy object automatically modifies the associated internal tables in case of user interactions. Sort and filter criteria are usually handled (saved and read) as parts of display variants. You can find more information on the structure of the internal tables for the sort and filter criteria in the online documentation. If the table to be displayed contains many fields, the user may be overwhelmed by the structure of the dialog boxes for selecting fields (columns) which are presented during interactions. For this reason, you can use the field catalog to group fields into logical groups (field groups). Using an internal table, you can pass texts for the field groups to the proxy object.
BC412 5-18

(C) SAP AG

0.18
Layout Information for the Data Area: Overview

LVC_S_LAYO

Structure type in the ABAP Dictionary for the control layout

General display options Grid customizing Totals options Exceptions Interactive control Drag&Drop control settings Colors

Optimize column width, title size, ... Gridlines on/off, column headers off, ... Totals display before single records yes/no, ... Indicate with traffic-light symbols yes/no, ... Detail screen properties, key columns ... Drag&Drop control settings List colors

© SAP AG 1999

You can influence the control layout using a structure of type LVC_S_LAYO (structure type in the ABAP Dictionary). The structure type LVC_S_LAYO contains the following information:  General display options (optimize column width, title size, ...)  Grid customizing (horizontal/vertical gridlines on/off, use column headers, ...)  Totals options (totals display before single records, ...)  Exception handling (use traffic light symbols, ...)  Interactive control (properties of the detail screen, ...)  Drag&Drop settings  Colors (print lists with striped pattern, ...) For more details, see the online documentation.

(C) SAP AG

BC412

5-19

Inactive functions that have originally be assigned to icons in the toolbar will not be displayed. The class constants each begin with mc_fc_. Table type UI_FUNCTIONS uses the field ui_func as the row type.    (C) SAP AG BC412 5-20 . you can use the field no_toolbar of structure LVC_S_LAYO..0.19 Layout Information for the Toolbar UI_FUNCTIONS Table type in the ABAP Dictionary ui_func (C70) Row type in the ABAP Dictionary: data element Structure f_code1 f_code2 f_code3 f_code4 Internal table of type UI_FUNCTION (only one column) Contains the function codes of the standard functions to be disabled (hidden) © SAP AG 1999  You can control the set of functions that are active in the toolbar using an internal table of type UI_FUNCTIONS (table type in the ABAP Dictionary). The class cl_gui_alv_grid has one class constant for each standard function. To hide the entire toolbar. you can set standard functions to inactive. you should use class constants of the class cl_gui_alv_grid.. Using the internal table. To do this.. Inactive functions that have originally be assigned to a menu item are displayed disabled. you fill the internal table with the function codes of the functions that you want to disable. To set a value for field ui_func.

The parameter applies for print lists only. You do not need this parameter if you print lists interactively using the frontend control. in this context. and the total number of list lines also appear on the print list. If you set the field prntlstinf to 'X'. you can determine the number of lines required for the page footer (END-OF-PAGE). Using parameter reservelns.0. you can use the ALV Grid Control as the default interface for printing: The table passed is directly formatted as an ABAP print list and placed into the spool. The other fields of the structure are not used for the ALV Grid Control. you can determine if you want to print a line after a group change (default setting) or if you want to have a page break (if you want to have a page break. you can make settings for the print list.      (C) SAP AG BC412 5-21 . If you set parameter print to value 'X'. Using field grpchgedit.20 Layout Information for the Print List LVC_S_PRNT Structure type in the ABAP Dictionary: print parameters print reservelns grpchgedit prntlstinf Print output yes/no Line number for END-OF-PAGE Group change formatting yes/no Do not print list info yes/no © SAP AG 1999  Using the fields print. any settings made interactively such as filter criteria. reservelns. you must set the field to 'X'). grpchedit and prntlsinf of structure LVC_S_PRNT. any interactive screen output is not processed.

0.21 Features Overview: Screen/Print List Features Features Technical view Technical view Screen and print list Screen and print list Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-22 .

you can display a toolbar. You can hide the toolbar completely.  Below the header is the area in which the list data is displayed (data area). (C) SAP AG BC412 5-23 . you can display a single-line list header.0.22 Screen Layout of the ALV Grid Control Toolbar List header Toolbar Functions can be hidden Pushbuttons and menu options can be added Functions are triggered as events List header Optional Single-line Data area Further structured Data display area (grid) © SAP AG 1999  The ALV Grid Control screen consists of three areas:  In the header area of the control area.  Below the toolbar. The calling program determines which functions are active.

entire rows and/or entire columns.. Drag&Drop operations are supported.        (C) SAP AG BC412 5-24 . For more information. If the data table contains more rows and more columns than can be displayed in the control area. You can determine if you want to have horizontal and vertical gridlines for the cell structure. Optionally. Key columns have a fixed position and therefore remain unchanged when the user scrolls horizontally through the list. The data passed as an internal table is displayed as a table. Selection keys (optional) © SAP AG 1999 Area for key columns (fixable) Scroll bars   The data area itself also has a structure of its own. horizontal and vertical scroll bars are available to go to a specific list position. Key columns have another color than non-key columns. You can logically group columns into key columns and non-key columns. see the online documentation. The columns can have headers. You can hide the column headers.Single cells . You can define the items users can select.23 Data Area Layout Column headers (can be hidden) Area for scrollable columns Colors can be used Striped patterns can be used (only print list) User can select (based on setting): .Entire rows/columns Column headers can be used Gridlines can be shown/ hidden Context menus Drag&Drop . It is possible to select cells (cell areas).0.. You can make any column in your data table a key column. The ALV Grid control supports context menu handling. you can display a selection column as the first column in the data area that can be used to select entire rows.

The logical organization of the complete list into cover page. a logical final page and any number of other pages in between that contain the actual list data. pages. page body and page footer is made possible by events (details to follow later).Page footer This is controlled through events and layout information for the list Subtotals can also be output by means of an event (control levels) Cover page Page header Page 1 Page body Page footer Page Page n Final page © SAP AG 1999  The print list layout is similar to the list layout of "classic" reporting:  The list can consist of a logical cover page.Page header .  In addition to the page body. and the organization of the individual pages into page header.  (C) SAP AG BC412 5-25 .0.Page body .Final page Each page can be organised in . each page can have a page header and a page footer.Cover page .24 Print List Layout Complete layout Page layout List properties List can be organised in pages .Pages . final page.

25 ALV Grid Control Overview: Method Overview Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-26 .0.

(C) SAP AG BC412 5-27 . Only class cl_gui_alv_grid is instantiated by applications.0.26 Inheritance Hierarchy cl_gui_object cl_gui_control cl_gui_alv_grid_base cl_gui_alv_grid © SAP AG 1999   Class cl_gui_alv_grid has the inheritance hierarchy specified.

0.  (C) SAP AG BC412 5-28 . see the online documentation. and variants  Methods for event handling and function code handling  Methods for connecting the control to the report-report interface For details on methods and interfaces.27 ALV Grid Control: Method Overview (1) Elementary methods Read/change Grid Control properties Read/ Layout and structure information Operations on / information about Filter criteria Sort criteria Variants Event handling / function codes Report / report interface © SAP AG 1999  The methods of the ALV Grid Control can be subdivided into:  Elementary methods  Methods for changing/reading the properties of the Grid Control  Methods for changing/reading the layout  Methods for operations on filter criteria. sort criteria.

layout information to control Inform control that data. Send data. event type.28 ALV Grid Control: Elementary Methods Elementary methods constructor set_table_for_first_display refresh_table_display Link with container.0. data descriptions or layout have been changed © SAP AG 1999  The ALV Grid Control has three elementary methods:  The constructor  Method set_table_for_first_display  Method refresh_table_display.. .. (C) SAP AG BC412 5-29 . data descriptions.

 i_appl_events: You use this parameter to determine if all events of your ALV Grid Control instance should be registered as system events (default) or as application events (value 'X').. The constructor for ALV Grid Control instances has four interface parameters:  i_shellstyle: You use this parameter to determine the general appearance of the control (for details. (C) SAP AG BC412 5-30 .. Container reference All registered events as application events: ' ' : Yes 'X' : No © SAP AG 1999   Optional parameters are shown as (ABAP) comments. CREATE OBJECT my_alv EXPORTING * i_shellstyle = * i_lifetime = i_parent = * i_appl_events = EXCEPTIONS . Possible values are: lifetime_imode (default).  i_lifetime: You use this parameter to influence the lifetime of the frontend control..0.. lifetime_dynpro (for details. . see the online documentation).  i_parent: You use this parameter to pass a container reference. The proxy object registers the ALV controls at the Control Framework. see the online documentation).29 The Constructor DATA: my_alv TYPE REF TO cl_gui_alv_grid.

BC412 5-31        (C) SAP AG . it_ = internal table. (For details. The proxy object then generates the field catalog automatically. you must additionally use parameter it_fieldcatalog. it_special_groups and it_toolbar_excluding allow you to pass your settings for the control layout and the print list. and any additional information to the ALV Grid Control instance. This is the default setting of the parameter... as well as the names of the field groups and the names of the functions to be disabled in the toolbar. is_ = structure. you can determine that a display variants should be loaded as default variant. is_print. Using parameter i_default.0. Using parameters it_filter and it_sort.30 Method SET_TABLE_FOR_FIRST_DISPLAY CALL METHOD my_alv->set_table_for_first_display EXPORTING * i_structure_name = Field catalog: name of a Dictionary structure catalog: * is_variant = * i_save = Variant control parameter * i_default = * is_layout = Structure for control layout * is_print = Structure for print list layout * it_special_groups = Internal table with texts for the field groups * it_toolbar_excluding = Internal table with functions to be hidden CHANGING it_outtab = Internal table with list data * it_fieldcatalog = Internal table with the field catalog * it_sort = Internal table with initial sort criteria * it_filter = Internal table with initial filter criteria EXCEPTIONS . see the online documentation. you use parameter it_outtab. You pass the name of the row structure of the data table using parameter i_structure_name. The interface parameters use the following name conventions: i_ = single field. To pass the list data to be displayed. Parameters is_layout. see the section The field catalog of this unit). you can pass initial filter and sort criteria to your proxy object. © SAP AG 1999  You can use method set_table_for_first_display to pass the list data. If you want to pass a field catalog that was generated manually or semi-automatically. For details on the method and the interface parameters. the field catalog. You use parameters is_variant and i_save to control the use of display variants.

you can determine that only the data content is to be sent again (filter and sort criteria remain unchanged).31 Method REFRESH_TABLE_DISPLAY CALL METHOD my_alv->refresh_table_display EXPORTING * is_stable = Refresh with stable columns/rows columns/ * i_soft_refresh = Update data only. Important: If you change the structure of your data table you have to call method set_table_for_first_display again. . Using parameter i_soft_refresh. the proxy object sends the list data and the display information once more to the frontend control. criteria. you can determine that any scroll positions that may exist should be kept (with reference to rows and columns) when the data is refreshed.    (C) SAP AG BC412 5-32 . Informs proxy object that the  Content of the internal table with list data and/or  Data objects for additional information have changed Update display at the frontend © SAP AG 1999  If you use method refresh_table_display. no sort criteria.0. Using the fields of parameter is_stable. and so on only.

i_save = SPACE. A: The user can save display variants both as user-specific and as global. " Only user-specific 'X'. you can determine the behavior of your proxy object with regard to display variant handling. you pass a structure of the type disvariant to parameter is_variant in which the field report has the value sy-repid. © SAP AG 1999  Using parameters is_variant and i_save. The value you assign to parameter i_save allows you to control the user save mode for display variants: U: The user can save display variants only as user-specific. i_save = SPACE.  The user can select. is_variant i_save i_save i_save = = = = <structure_name>. 'U'.  The user can select and change display variants: To set this mode. " Global and user-specific Change current display variant Select and change current display variant Select. and set parameter i_save to SPACE.  (C) SAP AG BC412 5-33 . you set both parameters to SPACE (default value).0. X: The user can save display variants only as global. change and save current display variant DATA: <structure_name> TYPE disvariant. is_variant = <structure_name>. and save display variants: To set this mode. change. you assign the same value to parameter is_variant as with the above mode. There are three modes which you can set with the help of these two parameters:  The user can change the current display variant: To set this mode. " Only global 'A'.32 Display Variants MODE Parameter value in method SET_TABLE_FOR_FIRST_DISPLAY is_variant = SPACE.

33 ALV Grid Control: Method Overview (2) Read/change properties of the Grid Control Read/ Cells Scroll bars Columns Rows Layout and structure information Field catalog Layout Frames © SAP AG 1999  The ALV Grid Control has methods for the following subobjects that allow you to access the properties of these subobjects in change or read mode:  Cells  Scroll bars  Columns  Rows The methods for the layout and the structure information can be subdivided as follows:  Methods for the field catalog  Methods for the layout  Methods for the general control layout (frames) For details on the method names and the interfaces.0. see the online documentation.   (C) SAP AG BC412 5-34 .

34 ALV Grid Control Overview: Event Overview Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-35 .0.

35 ALV Grid Control: Events Events during print list creation Mouse operations double_click hotspot_click User-defined functions User-defined before_user_command user_command after_user_command toolbar menu_button Context menus Drag&Drop Drag& © SAP AG 1999 Double-click on a cell Click on a cell hotspot Before execution of a standard function User-defined function code is triggered After execution of a standard function Toolbar is changed A menu option is changed  The ALV Grid Control has the following event types:  Events that mark a specific point during print list creation  Events for mouse operations Double-clicks on a cell Click on a hotspot of a cell  Events that allow you to Execute implementations for self-defined functions Change the process flow of the standard functions  Events for context menus  Events for Drag&Drop operations For details on the event names and interfaces. see the online documentation.  (C) SAP AG BC412 5-36 .0.

 (C) SAP AG BC412 5-37 .36 BEFORE_USER_COMMAND and AFTER_USER_COMMAND Frontend control Proxy instance ABAP program User triggers standard function before_user_command before_ user_ Implementation 1 Implementation of standard function after_user_command after_user_ Implementation 2 © SAP AG 1999  The events before_user_command and after_user_command allow you to run self-defined processes directly before and after the execution of a standard function.0. You can suppress the standard implementation of a standard function. To achieve this call the instance method set_user_command at the event for before_user_command and pass SPACE to the parameter i_ucomm.

END-OF-SELECTION. TOP-OF-PAGE and END-OF-PAGE in "classic" reporting. print_end_of_list. You can use event subtotal_text to output texts for subtotals lines that are not shown.0.   (C) SAP AG BC412 5-38 .37 ALV Grid Control: Print List Events Events during print list creation print_end_of_list print_top_of_list print_end_of_page print_top_of_page subtotal_text Corresponds to event END-OF-SELECTION for list Corresponds to event START-OF-SELECTION for list Corresponds to list event END-OF-PAGE Corresponds to list event TOP-OF-PAGE Subtotals texts of suppressed lines © SAP AG 1999  You can use events print_top_of_list. print_top_of_page. see the online documentation. and print_end_of_page to implement the logical processing steps that correspond to the events START-OF-SELECTION. For more details.

0.38 ALV Grid Control Overview: The Field Catalog Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog © SAP AG 1999 (C) SAP AG BC412 5-39 .

(C) SAP AG BC412 5-40 . 20000312 .. .... . .. . . . Field catalog: column properties 20001010 . carrid connid fldate . . .39 Recap: Functions of the Field Catalog ALV Grid Control / print list er op Pr Co nt en t s t ie Internal table itab with data carrid connid fldate AA AZ LH QA 0603 1702 0400 . .... Properties of column carrid Properties of column connid Properties of column fldate Properties of column . . 20000105 .. © SAP AG 1999  Recap: the field catalog is an internal table containing the properties of all columns of the data table.0. ..

0.40 Overview: Information in the Field Catalog LVC_S_FCAT Structure type in the ABAP Dictionary for the field catalog Column indicator Unit-specific formatting Output properties of columns Formatting of column contents Texts Technical column properties Other fields © SAP AG 1999 (C) SAP AG BC412 5-41 .

0.41 Field Catalog Overview: Information in the Field Catalog in Detail Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog Information in the field catalog in detail Information in the field catalog in detail Generating the field catalog Generating the field catalog © SAP AG 1999 (C) SAP AG BC412 5-42 .

Each column of the data table has a row in the field catalog. If a field is typed with reference to the ABAP Dictionary (automatically generated entry in the field catalog). seatsfree . . 12 .. .. . 0 .... 30 ..42 Field Catalog: Column Indicators Column indicators fieldname ref_field ref_table Example Internal table itab with data carrid . . .. .. .. Column name in data table Column with Dictionary reference: field name Column with Dictionary reference: structure name © SAP AG 1999  The column fieldname in the field catalog contains the names of the data table columns.0. ref_field ref_table SFLIGHT . . .   (C) SAP AG BC412 5-43 .. .. SEATSFREE . .... . .. .... see the online documentation.. Entries in the field catalog fieldname CARRID .. 70 . fields ref_field and ref_table contain the names of the reference field and the reference structure. . AA AZ LH QA . ... For more details.

you must enter the ID of that unit of measure in the column quantity. entries in the field cfieldname are ignored.43 Field Catalog: Unit-Specific Formatting Unit-specific formatting cfieldname currency qfieldname quantity Name of column for currency formatting Explicit currency ID for entire column Name of column for unit of measure formatting Explicit unit of measure for entire column © SAP AG 1999  Currency formatting:  If the content of a column is to be formatted based on the formatting options of a currency unit that is contained in another column of the data table. then you must specify the name of the column with the units of measure in the field qfieldname. you must enter the ID of that currency in the column currency.   (C) SAP AG BC412 5-44 . see the online documentation. For more details.  If a value is assigned to the field quantity.  If a value is assigned to the field currency.  If all values of a column are to be formatted according to a fixed unit of measure. Unit of measure formatting:  If the content of a column is to be formatted based on the formatting options of a unit of measure that is contained in another column of the data table.  If all values of a column are to be formatted according to a fixed currency. then you must specify the name of the column with the currency units in the field cfieldname.0. entries in the field qfieldname are ignored.

... ..00 USD 7000 ITL .. .44 Example: Currency Formatting Internal table itab with data carrid . . PRICE . ITL -> no decimal place). AA AZ .. CURRENCY . AA AZ . .. Entries in the field catalog fieldname CARRID .. . . .. .... © SAP AG 1999 Price Currency 300... .... ... ..... . Screen output / printing Fli.. . . The entry currency in field cfieldname for the column price in the field catalog determines that the entries of the column price are formatted according to the currency specified in the column currency (example: USD -> two decimal places...... cfieldname .  The above graphic shows the following: The data table contains the two columns price (amount to be paid for the flight) and currency (currency of price)....... .. ...0.. ... ....  (C) SAP AG BC412 5-45 . price currency 300 USD 7000 ITL .

 For more details. . but appears on the field selection dialog boxes for the standard functions (sort. bright. (C) SAP AG BC412 5-46 ..  tech: The column is hidden both in the list and on the field selection dialog boxes. filter. see the online documentation.45 Field Catalog: Output Properties for Columns Output properties for columns checkbox col_pos do_sum hotspot no_sum emphasize key lowercase no_out outputlen tech © SAP AG 1999 Display of a checkbox (no entry) Column position Totals calculation for column yes/no Column hotspot-sensitive yes/no Suppress totals calculation for column yes/no Highlight column content (color.. inverse) Column is key column yes/no Upper/lower case yes/no Do not output column yes/no Column width Do not output column yes/no  The following difference exists between no_out and tech:  no_out: The column is hidden in the list (screen or printout).0.).

0. For more details. 'L'. see the online documentation. 'C') (CHAR. NUMC) Suppress plus/minus signs yes/no Value 0 ('zero') not output yes/no Analogous to ROUND for WRITE Column name in data table for ROUND Display column content as symbol yes/no  Similar to the formatting options for currency fields. places Analogous to USING EDIT MASK for WRITE Window exponent for ABAP data type F Display column content as icon yes/no Leading zeros yes/no (NUMC) Adjust column content (' '.46 Field Catalog: Formatting of Column Contents Formatting of column contents decimals_o decmfield edit_mask exponent icon lzero just no_sign no_zero round roundfield symbol © SAP AG 1999 Number of decimal places (currencies) Column name in data table for number of dec. 'R'. I. F) either for individual column contents or for all entries of a column.  (C) SAP AG BC412 5-47 . you can use the fields decmfield and decimals_o to define the number of decimal places for numerical fields (ABAP data types P.

By assigning value 'L'. 'S') Freely definable text (column header) Copy from ABAP Dictionary Long text Medium text Short text Text selection for selection dialog box ('L'. the values of fields selddictext and tipddictext determine which text is to be displayed on the dialog boxes (interactive standard functions) and as the tool tip. the field reptext contains the headers from the data element (used for queries).0. the texts are copied from the Dictionary. these values override any entries in the fields colddictext. and tool tips (S = 'short'. M = ''middle'. 'S') Freely definable text (selection dialog box) Text selection for tooltip ('L'. selection screens. 'M'. Similarly. 'M'. 'S') Freely definable text (tooltip) © SAP AG 1999  Similar to the texts of a data element in the ABAP Dictionary. L = 'long'). For more details. dialog box texts and tool tips. the fields scrtext_l. For fields with reference to the Dictionary. 'M'. If you assign values to these fields. For fields with reference to the Dictionary. The fields coltext. scrtext_m and scrtext_s can contain three texts of different lengths for columns. seltext and tooltip allow you to use freely definable texts as column headers. you determine which text is to be used as the column header. selddictext and tipddictext. see the online documentation.     (C) SAP AG BC412 5-48 . 'M' or 'S' to field colddictext.47 Field Catalog: Texts Texts colddictxt coltext reptext scrtext_l scrtext_m scrtext_s selddictxt seltext tipddictxt tooltip Text selection for column headers ('L'.

48 Field Catalog: Technical Column Properties Used for fields without reference to ABAP Dic tionary types Technical column properties dd_outlen intlen rollname Output length (width) of column Internal column width F1 help by data element documentation: name of data element ABAP data type inttype © SAP AG 1999  For more details. (C) SAP AG BC412 5-49 .0. see the online documentation.

(C) SAP AG BC412 5-50 . For column A. Example: Suppose column A contains plant numbers. and column B the corresponding long texts. On the list.49 Field Catalog: Other Fields Other fields dragdropid reprep Drag&Drop control Link of column to report-report interface yes/no sp_group txt_field Identifier for field groups Column name for substitute texts for totals calculation © SAP AG 1999  You can replace numeric fields with a corresponding text using the txt_field field. Hamburg instead of 0001. the field txt_field must contain the name of column B (txt_field = 'B'). you want to display the text instead of the plant number (for example.0. refer to the online documentation.  For further details.

(C) SAP AG BC412 5-51 .  All of the other fields contain values for the attributes of the columns.  The field fieldname contains the column name.0.50 Summary: Structure of the Field Catalog Column name Dictionary relationship Properties FIELD CATALOG  ref_field ref_table Unit-specific formatting  Output Properties for Columns fieldname  Formatting of Column Contents  Texts  Technical Column Properties  Other Fields © SAP AG 1999  We can divide the fields in the field catalog into three groups according to their use in constructing the field catalog.  The fields ref_field and ref_table establish the relationship to any global types (fields of structures in the ABAP Dictionary).

51 Field Catalog Overview: Generating the Field Catalog Features Features Method overview Method overview Event overview Event overview The field catalog The field catalog Information in the field catalog in detail Information in the field catalog in detail Generating the field catalog Generating the field catalog © SAP AG 1999 (C) SAP AG BC412 5-52 .0.

In this case. the field catalog is generated according to a different procedure. Example: Row type SFLIGHT. you can have the entries of the fields with reference to the Dictionary generated automatically. Case 3: The row type of the data table contains only fields with local types. This means that the program that uses the ALV Grid Control must generate the field catalog on its own. We have to distinguish between three cases: Case 1: The row type of the data table is defined in the ABAP Dictionary. the field catalog must be generated manually. In this case. all information of the field catalog can be copied from the ABAP Dictionary. Case 2: The row type of the data table contains fields with types of fields of Dictionary structures and fields with local types.    (C) SAP AG BC412 5-53 .52 Generating the Field Catalog List data List data List data Row type of data table contains only Fields of a single Dictionary structure Row type of data table contains Row type of data table contains only Fields with local types  Fields of Dictionary structures  Fields with local types Field catalog is generated automatically © SAP AG 1999 Field catalog can be generated semi-automatically semi- Field catalog must be generated manually  Depending on the row type of the data table. while you must manually add the entries of the other columns to the field catalog (semiautomatic procedure). Example: The row type consists of the fields of structure SFLIGHT to which fields with types defined locally in the program have been added. In this case. This is done independently by the proxy object: The field catalog is generated automatically.0.

. SFLIGHT SPFLI ABAP Dictionary CALL METHOD my_alv->set_table_for_first_display EXPORTING i_structure_name i_structure_name = 'SFLIGHT' i_structure_ . 300 7000 . To do this. the ALV proxy object can create the field catalog automatically. specify the name of the ABAP Dictionary structure that corresponds to the line type of the data table in the i_structure_name parameter of the method set_table_for_first_display..... ..   (C) SAP AG BC412 5-54 ... CHANGING it_outtab = it_data it_outtab it_data it_ it_ . USD ITL .....0.. © SAP AG 1999  If the line type of the data table contains all of the fields in a particular ABAP Dictionary structure. The proxy object obtains all of the requisite information from the ABAP Dictionary and constructs the field catalog itself. ... ..53 Fields of a Single Dictionary Structure Internal table it_data with list data Row type: SFLIGHT AA AZ .

. To dothis.0. you:  Declare an internal table for the field catalog DATA: it_fcat TYPE lvc_t_fcat. and the name of the ABAP Dictionary structure to the i_structure_name parameter. CHANGING it_outtab = it_data it_ it_ it_fieldcatalog it_ ..  The proxy object then generates a full field catalog.54 Fields of a Dictionary Structure and Local Types Field catalog it_fcat Local ABAP types fill Cn DDIC 'empty' ABAP Dictionary STRUC send Cn = Column name Properties CALL METHOD my_alv->set_table_for_first_display EXPORTING i_structure_name = 'STRUC' i_structure_ .  Create an entry in the field catalog for each column in your data table that has a type that you defined locally in the program.  Call the instance method set_table_for_first_display and pass the data table (it_data in the graphic) to the it_outtab parameter.  (C) SAP AG BC412 5-55 . the field catalog (it_fcat) to the it_fieldcatalog parameter.. you can generate the field catalog semi-automatically. Enter the column name and define its attributes.. © SAP AG 1999 = it_fcat it_  If the row type of your data table consists of all fields of a single Dictionary structure to which other fields have been added.

Field catalog it_fcat DDIC Relation SFLIGHT SFLIGHT SFLIGHT SPFLI CITYFROM SPFLI CITYTO SPFLI . you must also specify the name of the reference field.  The proxy object then creates the full field catalog.  (C) SAP AG BC412 5-56 ..  Call the instance method set_table_for_first_display and pass the data table (it_data in the example) to the it_outtab parameter and the field catalog (it_fcat) to the it_fieldcatalog parameter..  Create an entry in the field catalog for each column in your data table. For fields where the column name in the data table is different to the field name in the ABAP Dictionary structure (cityfrom and cityto in the graphic).. Properties 'empty' send CALL METHOD my_alv->set_table_for_first_display .. you must:  Declare an internal table for the field catalog: DATA: it_fcat TYPE lvc_t_fcat.55 Fields of Several Dictionary Structures ABAP Dictionary SFLIGHT SPFLI Column fill CARRID CONNID FLDATE DEPTIME CITY_F CITY_T . ref_table the name of the reference table)... To do this. CHANGING it_outtab it_ it_fieldcatalog it_ .0.. © SAP AG 1999 = it_data it_ = it_fcat it_  You can also generate the field catalog semi-automatically if the fields in the line type of your data table have data types from more than one ABAP Dictionary structure.. Fill the fieldname and ref_table fields for all of the columns that have the same name as the structure field to which you referred to define their types (fieldname contains the column name.

.. fill the fieldname and ref_table columns (and ref_field if necessary).0. © SAP AG 1999 fill Local ABAP Types = it_data it_ = it_fcat it_  You can also generate the field catalog semi-automatically if the line type of your data table consists of fields from more than one ABAP Dictionary structure along with additional fields that have types that you defined locally in the program.  Create an entry in the field catalog for each column in your data table..  Call the instance method set_table_for_first_display and pass the data table (it_data in the example) to the it_outtab parameter and the field catalog (it_fcat) to the it_fieldcatalog parameter. For each column that has an ABAP Dictionary reference.56 Fields With and Without Dictionary Relationships ABAP Dictionary STRUC Cn Field catalog it_fcat DDIC Properties 'empty' 'empty' Cn = Column name send CALL METHOD my_alv->set_table_for_first_display . CHANGING it_outtab it_ it_fieldcatalog it_ .  (C) SAP AG BC412 5-57 .. create an entry in the field catalog by entering the column name and defining the attributes of the column. you must:  Declare an internal table for the field catalog: DATA: it_fcat TYPE lvc_t_fcat.  The proxy object then generates the full field catalog.  For each column in your data table that has a type that you defined locally in the program. To do this.

. Enter the column name and define the attributes for the columns. you must create the field catalog by hand..  Create an entry in the field catalog for each column in your data table. To do this. you must:  Declare an internal table for the field catalog: DATA: it_fcat TYPE lvc_t_fcat...  Call the instance method set_table_for_first_display and pass the data table (it_data in the example) to the it_outtab parameter and the field catalog (it_fcat) to the it_fieldcatalog parameter.  (C) SAP AG BC412 5-58 .0.57 Fields With Local Types Only Field catalog it_fcat fill Local ABAP types Cn DDIC 'empty' Properties Cn = Column name send CALL METHOD my_alv->set_table_for_first_display EXPORTING . CHANGING it_outtab it_ it_fieldcatalog it_ . © SAP AG 1999 = it_data it_ = it_fcat it_  If the line type of your data table consists exclusively of data types that you declared locally in the program.

(C) SAP AG BC412 5-59 . class Programs Demo for SLIS BCALV_GRID_01 BCALV_GRID_02 BCALV_GRID_03 BCALV_GRID_04 BCALV_GRID_05 BCALV_GRID_06 BCALV_GRID_07 BCALV_GRID_08 BCALV_GRID_09 BCALV_GRID_10 Events for print lists Basic and details lists with one instance Detail list in modal dialog box Exception handling (exceptions / traffic light symbols) Self-defined pushbuttons in the toolbar Context menus Self-defined menus in the toolbar Toolbar menu with standard pushbutton Control options for display variants Initial usage of display variants © SAP AG 1999   You can find demo programs for the ALV Grid Control in development class SLIS.58 Demo Programs Delivered Dev. This development class is delivered.0.

0.59 ALV Grid Control: Unit Summary Now you are able to:  Describe the features of the ALV Grid Control  Display list data in the ALV Grid Control  Read and change properties of the ALV Grid Control  Format print lists with the ALV Grid Control  Generate a field catalog © SAP AG 1999 (C) SAP AG BC412 5-60 .

Sign up to vote on this title
UsefulNot useful