Custom F4 functionality in WebDynpro for ABAP
I was looking for a custom solution for the F4-functionality in WebDynpro for ABAP, when I encountered the lack of information provided for the moment. Maybe the forum viewers would like to know what I’ve been doing with the information I requested. That’s why I decided to post an overview of the result.
I have to thank Rich Heilmann for the Using Select Options in a Web Dynpro(ABAP) Application he did on select option, it helped me almost at the point of delivery.
Get what you need
I started out by copying the selection template WDR_SELECT_OPTIONS that was allready there and just removed the button row out of the layout of the view SELECTION_SCREEN.
That way I had my own component for it ZKLAB_DEMO_HELP.
So far, so good. All I needed was the value help itself, so i created a component ZF4_PROFILE (because I’ll be looking for project profiles 😉 ). Double click on the component and add the component use of the freshly created help functionality.
and implement the needed interface for the value help.
Now go to the component controller and add an attribute M_LISTENER, this one will handle the events in the called popup.
In the properties you should define component use for the value_help you just selected, this will create the events automatically. In the methods I added the following:
method CANCEL .
METHOD selection_made .
DATA: ls_profile TYPE zklab_demo_profile.
wd_this->m_listener->f4_context_element->get_static_attributes( importing static_attributes = ls_profile ).
ls_profile-project_profile = id.
wd_this->m_listener->f4_context_element->set_static_attributes( ls_profile ).
method SET_VALUE_HELP_LISTENER .
wd_this->m_listener = listener.
For this I should redirect you to Rich’s blog . You just have to add a few things on top of that. I added a search and cancel button (instead of the continue button). And the actions linked to them as wel as the selection of a tableview row.
In the tableview I just added an onSelect action:
Retrieve the data from the select option
rt_profile = wd_this->m_handler->get_range_table_of_sel_field(
i_id = ‘S_PROJECT_PROFILE’ ).
Assign it to a field symbol
ASSIGN rt_profile->* TO .
Retrieve that data from the database. Normally it is suggested to
encapsulate the data retrieval in a separate class.
For simplicity, the SELECT statement has been implemented here.
CLEAR iscc. REFRESH iscc.
CALL FUNCTION ‘ZKLAB_GET_PROFILES’
profiles = lt_profiles
id = .
Bind the data to the context
node_profile = wd_context->get_child_node( name = `PROFILES` ).
node_profile->bind_elements( lt_profiles ).
METHOD onactionselected .
DATA: node TYPE REF TO if_wd_context_node,
elements TYPE wdr_context_element_set,
element TYPE REF TO if_wd_context_element,
selected_elements TYPE wdr_context_element_set,
row TYPE REF TO if_wd_context_element,
lv_line TYPE zklab_demo_propro,
lo_component type ref to IF_WD_COMPONENT. “#EC NEEDED
node = wd_context->get_child_node( ‘PROFILES’ ).
selected_elements = node->get_selected_elements( ).
READ TABLE selected_elements INTO row INDEX ‘1’.
IF sy-subrc EQ 0.
row->get_static_attributes( IMPORTING static_attributes = lv_line ).
node->set_attribute( name = ‘PROFIDPROJ’ value = lv_line-profidproj ).
wd_comp_controller->selection_made( lv_line-profidproj ).
METHOD wddoexit .
DATA: lr_usage TYPE REF TO if_wd_component_usage.
lr_usage = wd_this->wd_cpuse_select_options( ).
IF lr_usage->has_active_component( ) IS NOT INITIAL.
METHOD wddoinit .
lt_range_table TYPE REF TO data,
rt_range_table TYPE REF TO data,
read_only TYPE abap_bool,
typename TYPE string.
lr_componentcontroller TYPE REF TO ig_componentcontroller,
l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
create the used component
l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
wd_this->m_view ?= wd_this->wd_get_api( ).
get a pointer to the interface controller of the select options
init the select screen
create a range table that consists of this new data element
i_typename = ‘PROFIDPROJ’ ).
add a new field to the selection
i_id = ‘S_PROJECT_PROFILE’
it_result = lt_range_table
i_read_only = read_only ).
The called bapi is just a getlist function that works with range input ant table output. Now everything is set up on the side of the plugin, just creating a main screen left.
I went for only one view, with a series of inputfields, of which one is prepared with a custom F4 functionality. Therefor I needed to add the used components:
Include the components and interface in your main component.
Add the used components to you main view:
Select the attribute you want the Value help for in your context, and update the properties like this:
Now you should be able to see the following when you execute your main application:
use the F4
Select one and the (key)value is passed to the main screen.