Dynamic ABAP WebDynpro is extremely powerful. Here is an easy walkthrough example of reading a table at runtime to determine which tabs to dynamically create on your view.
Step 1: Create a WebDynpro Application like the following
Step 2: Create a Node called ROADMAP and an Attribute called STEP (type string) in your view context
Step 3: Create a Table Type which will be used to store runtime information for building the tabs
Step 4: In the attributes of your view, declare a table of your table type
Step 5: In the Actions of your view, declare a "SELECT" action
Step 6: In the WDINIT event, add some configuration to your table that you can use to build the tabs
data l_dyn_tabs type zphil_dyn_tabs.
l_dyn_tabs-guid = 'A'.
l_dyn_tabs-scrntext = 'TAB1'.
l_dyn_tabs-stype = '01'.
l_dyn_tabs-sposid = 01.
append l_dyn_tabs to wd_this->dyn_tabs.
l_dyn_tabs-guid = 'B'.
l_dyn_tabs-scrntext = 'TAB2'.
l_dyn_tabs-stype = '02'.
l_dyn_tabs-sposid = 02.
append l_dyn_tabs to wd_this->dyn_tabs.
l_dyn_tabs-guid = 'C'.
l_dyn_tabs-scrntext = 'TAB3'.
l_dyn_tabs-stype = '03'.
l_dyn_tabs-sposid = 03.
append l_dyn_tabs to wd_this->dyn_tabs.
Step 7: In the WDMODIFYVIEW event, build the tabs on the view (from your table configuration)
data l_ui_matrix_head_data type ref to cl_wd_matrix_head_data.
data l_container type ref to cl_wd_uielement_container.
data l_cl_wd_road_map type ref to cl_wd_road_map.
data l_step type ref to cl_wd_road_map_step.
data l_dyn_tabs type zphil_dyn_tabs.
data idx_counter type i.
if first_time = abap_true.
call method cl_wd_road_map=>new_road_map
exporting
id = 'MYROADMAP'
on_select = 'SELECT'
selected_step = 'ROADMAP.STEP'
receiving
control = l_cl_wd_road_map.
idx_counter = 0.
loop at wd_this->dyn_tabs into l_dyn_tabs.
idx_counter = idx_counter + 1.
call method cl_wd_road_map_step=>new_road_map_step
exporting
id = l_dyn_tabs-guid
description = l_dyn_tabs-scrntext
receiving
control = l_step.
call method l_cl_wd_road_map->add_step
exporting
index = idx_counter
the_step = l_step.
endloop.
l_ui_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data( l_cl_wd_road_map ).
l_cl_wd_road_map->set_layout_data( l_ui_matrix_head_data ).
l_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
call method l_container->add_child
exporting
the_child = l_cl_wd_road_map.
endif.
Step 8: Test your ABAP WebDynPro
As you can see, this is pretty simple and powerful. Of course, you would now need to put code into the ONACTIONSELECT method from your SELECT action. Depending on which TAB is selected (which you can read from the context), you would fire different plugs or you could even redraw the screen with different dynamic controls.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |