Dynamic Business Graphics – Airline Report

The business graphic chart gets updated every time the table showing the BEx query data changes its selection. Selected table rows represent chart series and table column names represent the chart categories.

The webdynpro table and business graphic are in separate views but share a common context node – CHARTDATA. Each time the end user selects one or more table rows CHARTDATA node gets updated and based on it so does the business graphic.

I. Update CHARTDATA based on table selection
In order to be used by the business graphic, CHARTDATA node needs to have a certain structure. It will have one attribute for chart category name (table column name) and additional attributes for each chart serie.

Each context element from CHARTDATA will contain the chart category/table column name under COLNAME and the corresponding table cell value from the intersection of COLNAME (table column) with SERIEx (selected row). Think of it as a sub table of the original BEx query table containing only the selected rows and having the rows switched with the columns.

colname1 10 10
colname2 20 20

II. Update business graphic based on CHARTDATA.
After we get a reference to the business graphic lr_graph, we create the chart series by looping through the CHARTDATA attributes. All represent chart series except the first one representing chart categories.

"update chart series
lr_graph->remove_all_series_list( ).
n_index = 0.
loop at ctx_node_attr_map into ctx_node_attr_info.
"1st attribute is chart column name, not related to series in any way
if n_index = 0.
add 1 to n_index.
"get chart serie binding path
concatenate 'CHARTDATA.SERIE' n_index into serie_path.
"create chart serie
lr_series = cl_wd_simple_series=>new_simple_series(
bind_value   = serie_path
label        = ctx_node_attr_info-default_value
lr_graph->add_series( lr_series ).
"update n_index
add 1 to n_index.

Chart categories are created very easily just by specifying the binding path to the CHARTDATA attribute containing the category names.
"update categories
lr_ctg  = cl_wd_category=>new_category( bind_description = 'CHARTDATA.COLNAME' ).
lr_graph->set_category( lr_ctg ).

This post is part of Airline Report.

Leave a Reply

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