Dynamic Tables – Airline Report

Now that BEx query data is reflected into a context node, we can use this node to create dynamic tables to show its content. The first column of the dynamic webdynpro table will always represent the query Y axis, the rest of the columns representing the query X axis.

Each time query data changes we update the dynamic table by removing it and re-creating it again with the help of the cl_wd_dynamic_tool class.
lo_table = cl_wd_dynamic_tool=>create_table_from_node(
ui_parent = lo_group
table_id = 'DB_TAB'
node = ctx_node

The above results in a table displaying the data from ctx_node node but with no column names. We can loop through ctx_node attributes and get the default attribute value holding the original query tuple name to update the column names. Column size in pixels also gets set here, to allow for column horizontal table scrolling if the table contains more columns than the available display area. Both table and table columns size needs to be set using the same unit, pixels or percent, for horizontal table scrolling to be working.

"update table columns header
lo_table_cols = lo_table->get_columns( ).
"loop through columns
col_idx = 1.
loop at ctx_node_attr_map into ctx_node_attr_info.
"make column caption
lr_caption = cl_wd_caption=>new_caption( ).
lr_caption->set_text( ctx_node_attr_info-default_value ).
"format column
read table lo_table_cols index col_idx into lo_table_col.
lo_table_col->set_header( EXPORTING the_header = lr_caption ).
lo_table_col->set_width( '120px' ).
add 1 to col_idx.
"various table characteristics
lo_table->set_selection_mode( CL_WD_TABLE=>E_SELECTION_MODE-MULTI ).
lo_table->set_width( '860px' ).
lo_table->set_scrollable_col_count( -2 ).
lo_table->set_fixed_table_layout( abap_true ).
"register events to table
lo_table->set_on_select( 'TABLESELECT' ).

This post is part of Airline Report.

Leave a Reply

Your email address will not be published. Required fields are marked *