One of the coolest features in the New ABAP WebDynpro is the ALV Grid with rich set of functionalities. Just reading through the Web Dynpro for ABAP documentation. I just happened to read a
very cool feature. You can display data in ALV plus represent the same as a business graphics just using a few additional lines of code.
Here is a simple application which displays the ALV data and Business Graphics at the same time. The necessary steps required are explained in the below steps. I belive they are
very much self explanatory and hence I am just providing the steps and the relavent screen shots.
Create a context node in the Component Controller
Attribute | Data Type |
YEAR | STRING |
PROFIT | I |
Add the ALV Component Usage
Map the Controller Component Context Node to the Interface Controller Usage
Embed the ALV Table view into the Window
!https://weblogs.sdn.sap.com/weblogs/images/31132/4.JPG|height=193|alt=image|width=450|src=https://we...!
Add the following code in the COMPONENTCONTROLLER WDDOINIT method
DATA: node_profit TYPE REF TO if_wd_context_node.
TYPES: BEGIN OF t_profit,
year TYPE string,
profit TYPE i,
END OF t_profit.
DATA: i_profit TYPE TABLE OF t_profit,
w_profit TYPE t_profit.
CLEAR w_profit.
w_profit-year = '2001'.
w_profit-profit = 2000.
APPEND w_profit TO i_profit.
CLEAR w_profit.
w_profit-year = '2002'.
w_profit-profit = 2200.
APPEND w_profit TO i_profit.
CLEAR w_profit.
w_profit-year = '2003'.
w_profit-profit = 2500.
APPEND w_profit TO i_profit.
CLEAR w_profit.
w_profit-year = '2004'.
w_profit-profit = 2400.
APPEND w_profit TO i_profit.
CLEAR w_profit.
w_profit-year = '2005'.
w_profit-profit = 2500.
APPEND w_profit TO i_profit.
node_profit = wd_context->get_child_node(
name = if_componentcontroller=>wdctx_profit ).
node_profit->bind_table( i_profit ).
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
DATA:
l_value TYPE REF TO cl_salv_wd_config_table.
l_value = l_ref_interfacecontroller->get_model(
).
l_value->if_salv_wd_table_settings~set_visible_row_count( '5' ).
DATA: l_ref_config_table TYPE REF TO if_salv_wd_table_settings,
l_display_as TYPE salv_wd_constant VALUE '02'.
l_ref_config_table ?= l_value.
l_ref_config_table->set_display_as(
value = l_display_as ).
The Result
Many people would prefer the data to be displayed as business graphics than tables. How about a mix of both, no one will say no for that I believe.