ALV
ALV
ALV
ROGBILLS - Synchronize billing plans ROGBILLS - Synchronize billing plans This documentation is copyright by SAP AG.
Functionality
You can use the ALV object model to apply tables in three different ways:
as a simple, two-dimensional table ( CL_SALV_TABLE class) as a hierarchically-sequential table ( CL_SALV_HIERSEQ_TABLE class) as a tree structure (CL_SALV_TREE class)
The following paragraphs deal relate to this table. Display types You can display the ALV tree structure in the following ways:
The tree structure takes up the entire screen. As a result, you can only display one tree. The screen is part of ALV. in a SAP GUI container
You create a container of the CL_GUI_CONTAINER class on your screen.The tree structure is displayed in this container. With this display type you can, for example, display more than one tree structure on the screen or mix the output with other SAP Enjoy controls. Special features of the ALV tree structure Term definitions When working with the ALV tree structure, you use the elements that you familiar with from working with other ALV displays. In addition, you will encounter the following terms:
Nodes
Every row of the tree structure (except those with column titles) is referred to as a node. Branch and leaf
You can make settings as to whether a node is displayed as a branch with furthersublevels, or as a leaf at the end of the branch. A branch is indicated with an arrow, the expander. By clicking on the expander, the user either displays or hides the sublevels of a branch. Note: You can also display a leaf as though it was a branch whose sublevels were currently hidden.
Item
The individual cells of a node are referred to as items in the tree structure. Procedure when working with the tree structure For the othertwo ALV worktools, you simply specify internal data tables to display the structure and data records. To display the ALV tree structure, proceed as follows:
To display the columns in the tree structure, you enter an empty table, the initial table. In other words, a table
that contains all the information about set up and sequence of columns, but no data records.
You create the nodes one after another for the tree structure: Every data record of the table that contains
exactly the structure for the empty table described above, represents one node. For every node, you specify which position and on which level you want to add it to the tree structure.
Recommendations and restrictions You use ALV primarily to display structured data clearly on the screen, and to make meaningful use of this data with the help of specific functions. Basically, the following applies: The performance behavior of ALV depends on different factors,in particular, on the displayed data quantity and number of aggregation conditions. If you have to decide whether and in what way you apply ALV, check whether the general conditions allow the use of ALV. The following restrictions apply for the use of ALV:
The number of columns is restricted to 90. The output length of a column is restricted to 128 characters. ALV is structured in such a way so that the user works primarily with your tables. ALV providesseveral basic
functions for printing your table, it is not intended for configuring the narrowed-down print layout. For aggregatable columns, ensure that the internal length of the column is large enough not just for the single
values but also for the result. The output is column-oriented. You can only display flat-structured tables. You cannot display nested tables
and structures. Tables displayed with ALV are not available for input. If you apply the tree structure in the container, you cannot use batch mode. The output of totals and subtotals is handled solely by ALV. You can neither pass the results to your
application nor manipulate them in any way. Methods The CL_SALV_TREE class contains the following methods:
Create instance FACTORY Display table DISPLAY Control the display of the table GET_METADATA GET_TREE_SETTINGS Container display only: Ensures that the metadata is the current data of the front end Returns the CL_SALV_TREE_SETTINGSclass object with which you Displays the ALV table Creates an instance of the ALV table object. Here, you determine the display type.
control the display of the tree structure GET_COLUMNS GET_AGGREGATIONS Settings for interaction GET_EVENT GET_SELECTIONS SET_DATA Toolbar GET_FUNCTIONS GET_FUNCTIONS_BASE Returns the CL_SALV_FUNCTIONS_TREEclass object with which you set the functions of your output table For internal use only. Do not use Returns the CL_SALV_EVENT class object with which you manage the events Returns the CL_SALV_SELECTIONS class object with which you specify the table selections Sets a new internal data table Returns the CL_SALV_COLUMNS_TREE class object with which you make the column settings Returns the CL_SALV_AGGREGATIONS class object with which you process aggregation settings
Design of header and footer information The following methods each reference one object of theCL_SALV_FORM_ELEMENT class; you use this object to design the header or footer of the list:
Returs the information about the list header area (online) Returns the information about the list footer area (online) Sets the information about the list header area (online) Sets the information about the list footer area (online)
GET_SCREEN_STATUS Returns the screen status SET_SCREEN_STATUS Sets the screen status for the full screen tree structure CLOSE_SCREEN Closes the screen status for the full screen tree structure
Relationships
The CL_SALV_TREE class contains the most important metadata objects through which you can control, forexample, the appearance, scope, and sort of the tree structure. In addition, you define here, for the full screen display of the tree structure, the areas above and below the output table (TOP_OF_LIST, END_OF_LIST).
Example
The following example shows the simplest call of a tree structure of the SFLIGHT type. Here, the gt_outtab2table is an empty table that only defines the structure of the tree. The gt_outtab1 table is the table that contains the desired data records. gr_tree reference to the ALV output class that is to be used. data: gt_outtab1 type table of sflight, gt_outtab2 type table of sflight. data: ls_outtab type sflight. data: gr_tree type ref to cl_salv_tree.
data: nodes type ref to cl_salv_nodes, node type ref to cl_salv_node, columns type ref to cl_salv_columns. data: key type salv_de_node_key. * Select Data select * from sflight into corresponding fields of table gt_outtab1 up to 5 rows. * Create Instance with an Empty Table call method cl_salv_tree=>factory IMPORTING R_SALV_TREE = gr_tree changing t_table = gt_outtab2.
* Add the Nodes to the Tree nodes = gr_tree->get_nodes( ). loop at gt_outtab1 into ls_outtab. try. node = nodes->add_node( related_node = key relationship = cl_gui_column_tree=>relat_first_child ). node->set_data_row( ls_outtab ). key = node->get_key( ). catch cx_salv_msg. endtry. endloop. columns = gr_tree->get_columns( ). columns->set_optimize( abap_true ). *Display Table gr_tree->display( ).
Notes
The SALV_DEMO_TREE_SIMPLE program contains a simple example of how you can implement the CL_SALV_TREE class.
Further information
Functionality
You can use the ALV object model to apply tables in three different ways:
The CL_SALV_HIERSEQ_TABLE class is derived from the CL_SALV_MODEL_LIST class. For the simplest callof a hierarchically-sequential table, you can program against the CL_SALV_HIERSEQ_TABLE table. It serves as an interface for the application developer. Special features of the hierarchically-sequential table You use the hierarchically-sequentialtable to display simple hierarchical structures. To do this, there are two hierarchy levels at yourdisposal. the header level and the item level. For each hierarchy level, you specify a table and the columns that connect the tables (foreign key relationship). You can only display the hierarchically-sequential table in the appearance of the classic ABAP list.The display types Full Screen or Container Control are not available for the hierarchically-sequential table. Most of the functions you might already be familiar with from other ALV table types are also availablefor the hierarchically-sequantial table (sort, filter, aggreations, and so on). Here, you also specify which of the two hierarchy levels you want to handle. Note: Every hierarchy level is an object of the CL_SALV_HIERSEQ_LEVEL class. Recommendations and restrictions You use ALV primarily to display structured data clearly on the screen, and to make meaningful use of this data with the help of specific functions. Basically, the following applies: The performance behavior of ALV depends on different factors,in particular, on the displayed data quantity and number of aggregation conditions (creation of subtotals).If you have to decide whether and in what way you apply ALV, check whether the general conditions allow the use of ALV. The following restrictions apply for the use of ALV as a hierarchically- sequential list:
The output length of a column is restricted to 128 characters. ALV is structured so that the user works with it on the screen. Although ALV provides several
basicfunctions for printing your table, it is not intended for configuring the narrowed-down print layout.
For sort and subtotals, you use a maximum of nine levels or columns. For aggregatable columns, ensure that the internal length of the column is large enough not
just for the single values, but also for the result.
The output is column-oriented. You can only display flat-structured tables. You cannot
Tables displayed with ALV are not available for input. The output of totals and subtotals is handled solely by ALV. You can neither pass the
Hierarchically-sequential lists consist of exactly two levels. These levels are connected to
each other through foreign key relationships. The number of these foreign key relationships is limited to5.
Both levels of the hierarchically-sequential list consist of two tables: the table for the header
Columns that are part of a foreign key relationship cannot be designed for an external sort. The sorting of hierarchically-sequential list is sorted according to your binary display (code
In the hierarchically-sequential list, you can build subtotals on header level only. In the simple, two-dimensional table, the system displays subtotals broken down according to
units,while in the hierarchically-sequential table, events are only displayed when the entire column contains a single unit. Methoden The CL_SALV_HIERSEQ_TABLE class contains the following methods:
Create instance FACTORY Display table Creates an instance of the ALV table object. Here, you determine the display type.
Returns the CL_SALV_DISPLAY_SETTINGSclass object with which you control the display of the output table Returns the CL_SALV_COLUMNS_LIST class object with which you make the column settings Returns the CL_SALV_FILTERS class object with which you make all filter settings Returns the CL_SALV_SORTS class object with which you make the settings for all the sort information Returns the CL_SALV_AGGREGATIONS class object with which you process all aggregation settings Returns the CL_SALV_PRINT class object with which you make all printer settings
GET_COLUMNS
GET_FILTERS
GET_SORTS
GET_AGGREGATIONS
Returns the CL_SALV_LAYOUT class object with which you make the settings for layout management Returns the CL_SALV_EVENT class object with which you manage the events
GET_EVENT
Returns the CL_SALV_FUNCTIONAL_SETTINGSclass object with GET_FUNCTIONAL_SETTINGS which you predominantly manage the technical environment of your output table GET_SELECTIONS REFRESH SET_DATA Toolbar GET_FUNCTIONS GET_FUNCTIONS_BASE Returns the CL_SALV_FUNCTIONS_LISTclass object with which you set the functions of your output table For internal use only. Do not use Returns the CL_SALV_SELECTIONS class object with which you specify the table selections Refreshes the display Sets a new internal data table
Design of header and footer information The following methods each reference one object of theCL_SALV_FORM_ELEMENT class; you use this object to design the header or footer area of the list:
GET_TOP_OF_LIST GET_END_OF_LIST
Returns the information about the list header area on the screen Returns the information about the list footer area on the screen
GET_TOP_OF_LIST_PRINT Returns the information about the list header area in the printout GET_END_OF_LIST_PRINT Returns the information about the list footer area in the printout SET_TOP_OF_LIST SET_END_OF_LIST Sets the information about the list header area (online) Sets the information about the list footer area (online)
SET_TOP_OF_LIST_PRINT Sets the information about the list header area (in printout) SET_END_OF_LIST_PRINT Sets the information about the list footer area (in printout) SET_MODUS Window settings GET_SCREEN_STATUS GET_SCREEN_POPUP SET_SCREEN_STATUS SET_SCREEN_POPUP CLOSE_SCREEN Returns the screen status Returns the dialog window coordinates Sets the screen status Sets the dialog window coordinates Closes the window in the case of ABAP list or full screen table If TOL > 65 lines: Enable processing anyway.
Relationships
The CL_SALV_HIERSEQ_TABLE class contains the most important metadata objects through which you can control,for example, the appearance, scope, and sort. In addition, you define here the areas above and below the output table (TOP_OF_LIST, END_OF_LIST).
Example
The following example shows the simplest call of a hierarchically- sequential table. The headerlevel comes from the SCARR table, while the item level comes from the SFLIGHT table. Their columns are transferred to the tables for your application data: gt_master or gt_slave. Both tables contain the CARRID column, upon which the foreign key relationship is built. gr_table is the reference to the ALV output class that is to be used.
data: gt_master type table of SCARR. data: gt_slave type table of SFLIGHT. data: gr_table type ref to cl_salv_hierseq_table. data: lt_binding type salv_t_hierseq_binding. data: ls_binding type salv_s_hierseq_binding. *... Select data select * from SCARR into corresponding fields of table gt_master. select * from SFLIGHT into corresponding fields of table gt_slave. *... Bind Master and Slave Table ls_binding-master = 'CARRID'. ls_binding-slave = 'CARRID'. append ls_binding to lt_binding. *... Create Instance call method cl_salv_hierseq_table=>factory exporting t_binding_level1_level2 = lt_binding importing r_hierseq = gr_table changing t_table_level1 = gt_master t_table_level2 = gt_slave. *... Display table gr_table->display( ).
Notes
The SALV_DEMO_HIERSEQ_SIMPLE program contains a simple example of how you can implement the CL_SALV_HIERSEQ_TABLE class.
Further information